I have such a cycle ...
while (true) { scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet(); for (SearchHit hit : scrollResp.getHits()){ // does this when totalHits > scrollSize, skips it otherwise } //Break condition: No hits are returned if (scrollResp.hits().hits().length == 0) { break; } }
The request scroll size is 500. When scrollResp.getHits (). totalHits () <500 a for loop is never entered. If I change scrollSize to be <totalHits, a for loop will be introduced.
In general, I expect> 500 results per query, but I need it to work anyway. Not sure if maybe I'm trying to iterate incorrectly or what. Feedback is welcome.
source share