Class SearchQueryThenFetchAsyncAction

java.lang.Object
org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction

public class SearchQueryThenFetchAsyncAction extends Object
  • Field Details

  • Method Details

    • executePhaseOnShard

      protected void executePhaseOnShard(SearchShardIterator shardIt, Transport.Connection connection, org.elasticsearch.action.search.SearchActionListener<SearchPhaseResult> listener)
      Sends the request to the actual shard.
      Parameters:
      shardIt - the shards iterator
      connection - to node that the shard is located on
      listener - the listener to notify on response
    • onShardGroupFailure

      protected void onShardGroupFailure(int shardIndex, SearchShardTarget shardTarget, Exception exc)
      Executed once for every ShardId that failed on all available shard routing.
      Parameters:
      shardIndex - the shard index that failed
      shardTarget - the last shard target for this failure
      exc - the last failure reason
    • onShardResult

      protected void onShardResult(SearchPhaseResult result)
      Executed once for every successful shard level request.
      Parameters:
      result - the result returned form the shard
    • getNextPhase

      protected org.elasticsearch.action.search.SearchPhase getNextPhase()
      Returns the next phase based on the results of the initial search phase
    • doRun

      protected void doRun(Map<SearchShardIterator,Integer> shardIndexMap)
    • notifyListShards

      protected void notifyListShards(SearchProgressListener progressListener, SearchResponse.Clusters clusters, SearchRequest searchRequest, List<SearchShardIterator> allIterators)
    • addReleasable

      public void addReleasable(Releasable releasable)
      Registers a Releasable that will be closed when the search request finishes or fails.
    • start

      public final void start()
      This is the main entry point for a search. This method starts the search execution of the initial phase.
    • run

      protected final void run()
    • performPhaseOnShard

      protected final void performPhaseOnShard(int shardIndex, SearchShardIterator shardIt, SearchShardTarget shard)
    • failOnUnavailable

      protected final void failOnUnavailable(int shardIndex, SearchShardIterator shardIt)
    • executeNextPhase

      protected void executeNextPhase(String currentPhase, Supplier<org.elasticsearch.action.search.SearchPhase> nextPhaseSupplier)
      Processes the phase transition from on phase to another. This method handles all errors that happen during the initial run execution of the next phase. If there are no successful operations in the context when this method is executed the search is aborted and a response is returned to the user indicating that all shards have failed.
    • onShardFailure

      protected final void onShardFailure(int shardIndex, SearchShardTarget shard, SearchShardIterator shardIt, Exception e)
    • getNumShards

      public final int getNumShards()
      Returns the total number of shards to the current search across all indices
    • getLogger

      public final org.apache.logging.log4j.Logger getLogger()
      Returns a logger for this context to prevent each individual phase to create their own logger.
    • getTask

      public final SearchTask getTask()
      Returns the currently executing search task
    • getRequest

      public final SearchRequest getRequest()
      Returns the currently executing search request
    • getOriginalIndices

      public OriginalIndices getOriginalIndices(int shardIndex)
      Returns the targeted OriginalIndices for the provided shardIndex.
    • isPartOfPointInTime

      public boolean isPartOfPointInTime(ShardSearchContextId contextId)
      Checks if the given context id is part of the point in time of this search (if exists). We should not release search contexts that belong to the point in time during or after searches.
    • sendSearchResponse

      public void sendSearchResponse(SearchResponseSections internalSearchResponse, AtomicArray<SearchPhaseResult> queryResults)
      Builds and sends the final search response back to the user.
      Parameters:
      internalSearchResponse - the internal search response
      queryResults - the results of the query phase
    • onPhaseFailure

      public void onPhaseFailure(String phase, String msg, Throwable cause)
      This method will communicate a fatal phase failure back to the user. In contrast to a shard failure will this method immediately fail the search request and return the failure to the issuer of the request
      Parameters:
      phase - the phase that failed
      msg - an optional message
      cause - the cause of the phase failure
    • getConnection

      public final Transport.Connection getConnection(String clusterAlias, String nodeId)
      Returns a connection to the node if connected otherwise and ConnectTransportException will be thrown.
    • getSearchTransport

      public SearchTransportService getSearchTransport()
      Returns the SearchTransportService to send shard request to other nodes
    • execute

      public final void execute(Runnable command)
    • buildShardSearchRequest

      protected final ShardSearchRequest buildShardSearchRequest(SearchShardIterator shardIt, int shardIndex)
      Builds an request for the initial search phase.
      Parameters:
      shardIt - the target SearchShardIterator
      shardIndex - the index of the shard that is used in the coordinator node to tiebreak results with identical sort values
    • getName

      public String getName()
      Returns the phases name.
    • doCheckNoMissingShards

      protected static void doCheckNoMissingShards(String phaseName, SearchRequest request, List<SearchShardIterator> shardsIts)
    • releaseIrrelevantSearchContext

      protected static void releaseIrrelevantSearchContext(SearchPhaseResult searchPhaseResult, org.elasticsearch.action.search.AbstractSearchAsyncAction<?> context)
      Releases shard targets that are not used in the docsIdsToLoad.