LOG.debug("[{}] Starting scroll request for query {}", queryHash, getOriginalQuery());
}
public ScrollChunk nextChunk() {
final SearchResponse search = client.prepareSearchScroll(scrollId)
.setScroll(TimeValue.timeValueMinutes(1))
.execute()
.actionGet();
final SearchHits hits = search.getHits();
if (hits.getHits().length == 0) {
// scroll exhausted
LOG.debug("[{}] Reached end of scroll results.", queryHash, getOriginalQuery());
return null;
}
LOG.debug("[{}] New scroll id {}", queryHash, search.getScrollId());
scrollId = search.getScrollId(); // save the id for the next request.
return new ScrollChunk(hits, fields, chunkId++);
}