要不要再翻翻文档呢?

5.x scroll 没有返回新id

Elasticsearch | 作者 jsh0401 | 发布于2017年12月01日 | 阅读数:3882

网上搜scroll的理解 是每次查询返回不同id,每次取上一个id找数据,然后产生新id,每次size*shard个数, 但是我代码打印出来的scroll_id却没变,查询结果应该是正确的,而且设置的szie就是每次返回的size,并没有乘以shard个数,请问为什么呢
 
代码如下:
 

scrollResp = client.prepareSearch(indexHash.get(index)) .setQuery(qb) .setScroll(TimeValue.timeValueMillis(10000)) .addSort(SortBuilders.fieldSort("_doc")) .setSize(10000) .execute().actionGet();

// 第一次查询,只返回数量和一个scrollId System.out.println(scrollResp.getScrollId()); System.out.println(scrollResp.getHits().getTotalHits()); System.out.println(scrollResp.getHits().hits().length); System.out.println("------------------------------");
 
 

public void getAllUuid() { 
do { 
 
for (SearchHit hit : scrollResp.getHits().getHits()) { 
System.out.println("uuid: " + hit.getSource().get("id")); 
break; 

scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()) .
setScroll(new TimeValue(10000)) .execute().actionGet(); 
 
System.out.println(scrollResp.getScrollId()); 
System.out.println(scrollResp.getHits().getTotalHits()); 
System.out.println(scrollResp.getHits().hits().length); System.out.println(++NUM + "------------------------------"); 
 
} while(scrollResp.getHits().getHits().length != 0); }
 
 
 
 
 
结果并没有陷入死循环,能遍历完结果
 
结果如下:
241------------------------------
uuid: 47ACF4AF0DA754A0071E370735C8B006|937768020839668
DnF1ZXJ5VGhlbkZldGNoHgAAAAAABS9CFkZtaTN5elV3VGlpbE5ScDRPelVsQ3cAAAAAAAXvIRZIUHpxcy1UVVNzQ0NwS2xGQm9qeEd3AAAAAAABaZQWaS1hQUw1U2hTb3F3WU42TllmcUxWQQAAAAAAAJNeFk5TZENPVHNkUXZlbU9TZDZEclJMbncAAAAAAAhYmBZaWWtvQ1Jvc1FMeVVjWEFCYU9GaTNRAAAAAAAAK9IWUzBSUmt0QzZUUlNxMjhNelZ0S0g1ZwAAAAAAACvTFlMwUlJrdEM2VFJTcTI4TX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