The requested URL was not found on this server. 不管你信不信,反正我是没找到

elasticsearch Scroll size问题

Elasticsearch | 作者 redhat | 发布于2018年07月13日 | 阅读数:5475


豆芽图片20180713111831608.png
import static org.elasticsearch.index.query.QueryBuilders.*;

QueryBuilder qb = termQuery("multi", "test");

SearchResponse scrollResp = client.prepareSearch(test)
.addSort(SortParseElement.DOC_FIELD_NAME, SortOrder.ASC)
.setScroll(new TimeValue(60000))
.setQuery(qb)
.setSize(100).execute().actionGet(); [b]//100 hits per shard will be returned for each scroll
[/b]//Scroll until no hits are returned
while (true) {

for (SearchHit hit : scrollResp.getHits().getHits()) {
//Handle the hit...
}
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
//Break condition: No hits are returned
if (scrollResp.getHits().getHits().length == 0) {
break;
}
}

.setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll
 
按照这句话的意思 返回的数量应该等于 shard count * size  ,但我事件测试时,一直都是返回100  求解
 
已邀请:

God_lockin

赞同来自: redhat

这个地方的size除了从所有分片里拿100之外,还会限制返回到你请求端的结果集为100
 
这里说的是,从所有分片(N个)里每个拿100,然后按条件排序,然后按scroll的方式每次返回100给你,一共能scrollN次

要回复问题请先登录注册