Search in sources :

Example 1 with SearchScrollRequestBuilder

use of org.elasticsearch.action.search.SearchScrollRequestBuilder in project wonderdog by infochimps-labs.

the class ElasticSearchStreamingRecordReader method fetchNextHits.

private void fetchNextHits() {
    if (scrollId == null) {
        LOG.info("Running initial scroll with timeout " + scrollTimeout);
        SearchRequestBuilder request = split.initialScrollRequest(client, scroll, requestSize);
        SearchResponse response = request.execute().actionGet();
        this.scrollId = response.getScrollId();
        LOG.info("Got scroll ID " + scrollId);
    // Do we need to call fetchNextHits() again here?  Or does
    // the initial request also itself contain the first set
    // of hits for the scroll?
    // 
    // fetchNextHits();
    } else {
        // LOG.info("Running query for scroll ID "+scrollId+" with timeout "+scrollTimeout);
        SearchScrollRequestBuilder request = split.scrollRequest(client, scroll, scrollId);
        SearchResponse response = request.execute().actionGet();
        this.scrollId = response.getScrollId();
        // LOG.info("Got scroll ID "+scrollId);
        this.hitsItr = response.getHits().iterator();
    }
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchScrollRequestBuilder(org.elasticsearch.action.search.SearchScrollRequestBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Aggregations

SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1 SearchScrollRequestBuilder (org.elasticsearch.action.search.SearchScrollRequestBuilder)1