Search in sources :

Example 1 with ScrollQuerySearchResult

use of org.elasticsearch.search.query.ScrollQuerySearchResult in project elasticsearch by elastic.

the class SearchService method executeQueryPhase.

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

Example 2 with ScrollQuerySearchResult

use of org.elasticsearch.search.query.ScrollQuerySearchResult in project elasticsearch by elastic.

the class SearchScrollQueryThenFetchAsyncAction method executeQueryPhase.

private void executeQueryPhase(final int shardIndex, final AtomicInteger counter, DiscoveryNode node, final long searchId) {
    InternalScrollSearchRequest internalRequest = internalScrollSearchRequest(searchId, request);
    searchTransportService.sendExecuteQuery(node, internalRequest, task, new ActionListener<ScrollQuerySearchResult>() {

        @Override
        public void onResponse(ScrollQuerySearchResult result) {
            queryResults.set(shardIndex, result.queryResult());
            if (counter.decrementAndGet() == 0) {
                try {
                    executeFetchPhase();
                } catch (Exception e) {
                    onFailure(e);
                }
            }
        }

        @Override
        public void onFailure(Exception t) {
            onQueryPhaseFailure(shardIndex, counter, searchId, t);
        }
    });
}
Also used : InternalScrollSearchRequest(org.elasticsearch.search.internal.InternalScrollSearchRequest) ScrollQuerySearchResult(org.elasticsearch.search.query.ScrollQuerySearchResult)

Aggregations

ScrollQuerySearchResult (org.elasticsearch.search.query.ScrollQuerySearchResult)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 InternalScrollSearchRequest (org.elasticsearch.search.internal.InternalScrollSearchRequest)1 SearchContext (org.elasticsearch.search.internal.SearchContext)1