Module org.elasticsearch.server
Package org.elasticsearch.action.search
Class SearchQueryThenFetchAsyncAction
java.lang.Object
org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRequest for starting the query phase for multiple shards.static final classResponse to a query phase request, holding per-shard results that have been partially reduced as well as the partial reduce result. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, AliasFilter> protected static final floatprotected final SubscribableListener<Void> static final Stringprotected final SearchRequestprotected final org.elasticsearch.action.search.SearchPhaseResults<SearchPhaseResult> protected final SearchTransportServiceprotected final SearchShardIterator[]protected final List<SearchShardIterator> protected final SearchTaskprotected final TransportSearchAction.SearchTimeProvider -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReleasable(Releasable releasable) Registers aReleasablethat will be closed when the search request finishes or fails.protected BytesReferencebuildSearchContextId(ShardSearchFailure[] failures) protected final ShardSearchRequestbuildShardSearchRequest(SearchShardIterator shardIt, int shardIndex) Builds an request for the initial search phase.protected static voiddoCheckNoMissingShards(String phaseName, SearchRequest request, List<SearchShardIterator> shardsIts) protected voiddoRun(Map<SearchShardIterator, Integer> shardIndexMap) final voidprotected voidexecuteNextPhase(String currentPhase, Supplier<org.elasticsearch.action.search.SearchPhase> nextPhaseSupplier) Processes the phase transition from on phase to another.protected voidexecutePhaseOnShard(SearchShardIterator shardIt, Transport.Connection connection, org.elasticsearch.action.search.SearchActionListener<SearchPhaseResult> listener) Sends the request to the actual shard.protected final voidfailOnUnavailable(int shardIndex, SearchShardIterator shardIt) final Transport.ConnectiongetConnection(String clusterAlias, String nodeId) Returns a connection to the node if connected otherwise andConnectTransportExceptionwill be thrown.final org.apache.logging.log4j.LoggerReturns a logger for this context to prevent each individual phase to create their own logger.getName()Returns the phases name.protected org.elasticsearch.action.search.SearchPhaseReturns the next phase based on the results of the initial search phasefinal intReturns the total number of shards to the current search across all indicesgetOriginalIndices(int shardIndex) Returns the targetedOriginalIndicesfor the providedshardIndex.final SearchRequestReturns the currently executing search requestReturns theSearchTransportServiceto send shard request to other nodesfinal SearchTaskgetTask()Returns the currently executing search taskbooleanisPartOfPointInTime(ShardSearchContextId contextId) Checks if the given context id is part of the point in time of this search (if exists).protected voidnotifyListShards(SearchProgressListener progressListener, SearchResponse.Clusters clusters, SearchRequest searchRequest, List<SearchShardIterator> allIterators) voidonPhaseFailure(String phase, String msg, Throwable cause) This method will communicate a fatal phase failure back to the user.protected final voidonShardFailure(int shardIndex, SearchShardTarget shard, SearchShardIterator shardIt, Exception e) protected voidonShardGroupFailure(int shardIndex, SearchShardTarget shardTarget, Exception exc) Executed once for everyShardIdthat failed on all available shard routing.protected voidonShardResult(SearchPhaseResult result) Executed once for every successful shard level request.protected final voidperformPhaseOnShard(int shardIndex, SearchShardIterator shardIt, SearchShardTarget shard) protected static voidreleaseIrrelevantSearchContext(SearchPhaseResult searchPhaseResult, org.elasticsearch.action.search.AbstractSearchAsyncAction<?> context) Releases shard targets that are not used in the docsIdsToLoad.protected final voidrun()voidsendSearchResponse(SearchResponseSections internalSearchResponse, AtomicArray<SearchPhaseResult> queryResults) Builds and sends the final search response back to the user.final voidstart()This is the main entry point for a search.
-
Field Details
-
NODE_SEARCH_ACTION_NAME
- See Also:
-
DEFAULT_INDEX_BOOST
protected static final float DEFAULT_INDEX_BOOST- See Also:
-
searchTransportService
-
request
-
task
-
results
-
aliasFilter
-
concreteIndexBoosts
-
timeProvider
-
shardsIts
-
shardIterators
-
doneFuture
-
-
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 iteratorconnection- to node that the shard is located onlistener- the listener to notify on response
-
onShardGroupFailure
Executed once for everyShardIdthat failed on all available shard routing.- Parameters:
shardIndex- the shard index that failedshardTarget- the last shard target for this failureexc- the last failure reason
-
onShardResult
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
-
notifyListShards
protected void notifyListShards(SearchProgressListener progressListener, SearchResponse.Clusters clusters, SearchRequest searchRequest, List<SearchShardIterator> allIterators) -
addReleasable
Registers aReleasablethat 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) -
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
Returns the currently executing search task -
getRequest
Returns the currently executing search request -
getOriginalIndices
Returns the targetedOriginalIndicesfor the providedshardIndex. -
isPartOfPointInTime
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 responsequeryResults- the results of the query phase
-
buildSearchContextId
-
onPhaseFailure
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 failedmsg- an optional messagecause- the cause of the phase failure
-
getConnection
Returns a connection to the node if connected otherwise andConnectTransportExceptionwill be thrown. -
getSearchTransport
Returns theSearchTransportServiceto send shard request to other nodes -
execute
-
buildShardSearchRequest
protected final ShardSearchRequest buildShardSearchRequest(SearchShardIterator shardIt, int shardIndex) Builds an request for the initial search phase.- Parameters:
shardIt- the targetSearchShardIteratorshardIndex- the index of the shard that is used in the coordinator node to tiebreak results with identical sort values
-
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.
-