spring data elasticsearch的一個複雜查詢條件
阿新 • • 發佈:2019-01-03
spring data elasticsearch的樣例文件真是太少,不得不去原始碼裡找test例子去看了半天,試出一個。
CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria()
.and(new Criteria("clusterName").is("app"))
.and(new Criteria("ip").is("127.0.0.1"))
.and(new Criteria("appType").is("download"))
.and(new Criteria("appName").is("appdownload"))
.and(new Criteria("fileName").is("appdownload.log"))
.and(new Criteria("logLeval").is("info"))
.and(new Criteria("produceDateTime").greaterThanEqual(
startDate.getTime()).lessThanEqual(endDate.getTime()))
.and(new Criteria("message").contains("haha"))).setPageable(
new PageRequest(0, 10)).addSort(
new Sort(new Sort.Order(Sort.Direction.DESC, "segEndlineNo")));
Page<LogEntity> pages = elasticsearchTemplate.queryForPage(criteriaQuery,
LogEntity.class);