Search in sources :

Example 1 with ScrollQueryFetchSearchResult

use of org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult in project elasticsearch by elastic.

the class SearchScrollQueryAndFetchAsyncAction method executePhase.

void executePhase(final int shardIndex, DiscoveryNode node, final long searchId) {
    InternalScrollSearchRequest internalRequest = internalScrollSearchRequest(searchId, request);
    searchTransportService.sendExecuteFetch(node, internalRequest, task, new ActionListener<ScrollQueryFetchSearchResult>() {

        @Override
        public void onResponse(ScrollQueryFetchSearchResult result) {
            queryFetchResults.set(shardIndex, result.result());
            if (counter.decrementAndGet() == 0) {
                finishHim();
            }
        }

        @Override
        public void onFailure(Exception t) {
            onPhaseFailure(t, searchId, shardIndex);
        }
    });
}
Also used : InternalScrollSearchRequest(org.elasticsearch.search.internal.InternalScrollSearchRequest) ScrollQueryFetchSearchResult(org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult)

Example 2 with ScrollQueryFetchSearchResult

use of org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult in project elasticsearch by elastic.

the class SearchService method executeFetchPhase.

public ScrollQueryFetchSearchResult executeFetchPhase(InternalScrollSearchRequest request, SearchTask task) {
    final SearchContext context = findContext(request.id());
    context.incRef();
    try {
        context.setTask(task);
        contextProcessing(context);
        SearchOperationListener operationListener = context.indexShard().getSearchOperationListener();
        processScroll(request, context);
        operationListener.onPreQueryPhase(context);
        final long time = System.nanoTime();
        try {
            queryPhase.execute(context);
        } catch (Exception e) {
            operationListener.onFailedQueryPhase(context);
            throw ExceptionsHelper.convertToRuntime(e);
        }
        long afterQueryTime = System.nanoTime();
        operationListener.onQueryPhase(context, afterQueryTime - time);
        QueryFetchSearchResult fetchSearchResult = executeFetchPhase(context, operationListener, afterQueryTime);
        return new ScrollQueryFetchSearchResult(fetchSearchResult, context.shardTarget());
    } catch (Exception e) {
        logger.trace("Fetch phase failed", e);
        processFailure(context, e);
        throw ExceptionsHelper.convertToRuntime(e);
    } finally {
        cleanContext(context);
    }
}
Also used : ScrollQueryFetchSearchResult(org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult) QueryFetchSearchResult(org.elasticsearch.search.fetch.QueryFetchSearchResult) SearchContext(org.elasticsearch.search.internal.SearchContext) SearchOperationListener(org.elasticsearch.index.shard.SearchOperationListener) ElasticsearchException(org.elasticsearch.ElasticsearchException) AggregationInitializationException(org.elasticsearch.search.aggregations.AggregationInitializationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ScrollQueryFetchSearchResult(org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult)

Aggregations

ScrollQueryFetchSearchResult (org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 SearchOperationListener (org.elasticsearch.index.shard.SearchOperationListener)1 AggregationInitializationException (org.elasticsearch.search.aggregations.AggregationInitializationException)1 QueryFetchSearchResult (org.elasticsearch.search.fetch.QueryFetchSearchResult)1 InternalScrollSearchRequest (org.elasticsearch.search.internal.InternalScrollSearchRequest)1 SearchContext (org.elasticsearch.search.internal.SearchContext)1