Ejemplo n.º 1
0
 public ScrollQueryFetchSearchResult executeScan(InternalScrollSearchRequest request) {
   final SearchContext context = findContext(request.id());
   contextProcessing(context);
   try {
     processScroll(request, context);
     if (context.searchType() == SearchType.QUERY_THEN_FETCH) {
       // first scanning, reset the from to 0
       context.searchType(SearchType.SCAN);
       context.from(0);
     }
     queryPhase.execute(context);
     shortcutDocIdsToLoadForScanning(context);
     fetchPhase.execute(context);
     if (context.scroll() == null || context.fetchResult().hits().hits().length < context.size()) {
       freeContext(request.id());
     } else {
       contextProcessedSuccessfully(context);
     }
     return new ScrollQueryFetchSearchResult(
         new QueryFetchSearchResult(context.queryResult(), context.fetchResult()),
         context.shardTarget());
   } catch (Throwable e) {
     logger.trace("Scan phase failed", e);
     processFailure(context, e);
     throw ExceptionsHelper.convertToRuntime(e);
   } finally {
     cleanContext(context);
   }
 }
Ejemplo n.º 2
0
 public ScrollQueryFetchSearchResult executeFetchPhase(InternalScrollSearchRequest request) {
   final SearchContext context = findContext(request.id());
   contextProcessing(context);
   try {
     ShardSearchStats shardSearchStats = context.indexShard().searchService();
     processScroll(request, context);
     shardSearchStats.onPreQueryPhase(context);
     long time = System.nanoTime();
     try {
       queryPhase.execute(context);
     } catch (Throwable e) {
       shardSearchStats.onFailedQueryPhase(context);
       throw ExceptionsHelper.convertToRuntime(e);
     }
     long time2 = System.nanoTime();
     shardSearchStats.onQueryPhase(context, time2 - time);
     shardSearchStats.onPreFetchPhase(context);
     try {
       shortcutDocIdsToLoad(context);
       fetchPhase.execute(context);
       if (context.scroll() == null) {
         freeContext(request.id());
       } else {
         contextProcessedSuccessfully(context);
       }
     } catch (Throwable e) {
       shardSearchStats.onFailedFetchPhase(context);
       throw ExceptionsHelper.convertToRuntime(e);
     }
     shardSearchStats.onFetchPhase(context, System.nanoTime() - time2);
     return new ScrollQueryFetchSearchResult(
         new QueryFetchSearchResult(context.queryResult(), context.fetchResult()),
         context.shardTarget());
   } catch (Throwable e) {
     logger.trace("Fetch phase failed", e);
     processFailure(context, e);
     throw ExceptionsHelper.convertToRuntime(e);
   } finally {
     cleanContext(context);
   }
 }
Ejemplo n.º 3
0
 public ScrollQuerySearchResult executeQueryPhase(InternalScrollSearchRequest request) {
   final SearchContext context = findContext(request.id());
   ShardSearchStats shardSearchStats = context.indexShard().searchService();
   try {
     shardSearchStats.onPreQueryPhase(context);
     long time = System.nanoTime();
     contextProcessing(context);
     processScroll(request, context);
     queryPhase.execute(context);
     contextProcessedSuccessfully(context);
     shardSearchStats.onQueryPhase(context, System.nanoTime() - time);
     return new ScrollQuerySearchResult(context.queryResult(), context.shardTarget());
   } catch (Throwable e) {
     shardSearchStats.onFailedQueryPhase(context);
     logger.trace("Query phase failed", e);
     processFailure(context, e);
     throw ExceptionsHelper.convertToRuntime(e);
   } finally {
     cleanContext(context);
   }
 }