Merge pull request #13526 from robertberg/rberg.searchdocs
Edit search scroll docs for syntactic style
This commit is contained in:
commit
cbdcdc1b96
|
@ -60,17 +60,13 @@ SearchResponse scrollResp = client.prepareSearch(test)
|
||||||
.setQuery(qb)
|
.setQuery(qb)
|
||||||
.setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll
|
.setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll
|
||||||
//Scroll until no hits are returned
|
//Scroll until no hits are returned
|
||||||
while (true) {
|
do {
|
||||||
|
|
||||||
for (SearchHit hit : scrollResp.getHits().getHits()) {
|
for (SearchHit hit : scrollResp.getHits().getHits()) {
|
||||||
//Handle the hit...
|
//Handle the hit...
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
|
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
|
||||||
//Break condition: No hits are returned
|
} while(scrollResp.getHits().getHits().length != 0); // Zero hits mark the end of the scroll and the while loop.
|
||||||
if (scrollResp.getHits().getHits().length == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
[[java-search-msearch]]
|
[[java-search-msearch]]
|
||||||
|
|
Loading…
Reference in New Issue