实例
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("app",app);
SearchQuery query = new NativeSearchQueryBuilder()
.withIndices(index)
.withTypes(type)
.withQuery(matchQueryBuilder)
.withPageable(page)
.build();
long scollTimeInMillis = 1000;
String scrollId = elasticsearchTemplate.scan(query, scollTimeInMillis, false);
boolean hasRecords = true;
long totalCount = 0;
while (hasRecords) {
Page<LogDetail> page = elasticsearchTemplate.scroll(scrollId, scollTimeInMillis, LogDetail.class);
if (page.hasContent()) {
LOGGER.info("page number:{}",page.getNumberOfElements());
totalCount += page.getNumberOfElements();
} else {
hasRecords = false;
}
}
//clear scroll
elasticsearchTemplate.clearScroll(scrollId);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。