java.lang.Object
org.elasticsearch.search.fetch.FetchPhase
Fetch phase of a search request, used to fetch the actual top matching documents to be returned to the client, identified
after reducing all the matches returned by the query phase
Supports both traditional mode (all results in memory) and streaming mode (results sent in chunks).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs) Executes the fetch phase without memory checking or streaming.voidexecute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs, IntConsumer memoryChecker) Executes the fetch phase with an optional caller-supplied memory tracking callback and no streamingvoidexecute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs, IntConsumer memoryChecker, FetchPhaseResponseChunk.Writer writer, Integer maxInFlightChunks, ActionListener<Void> buildListener, ActionListener<Void> listener) Executes the fetch phase with an optional caller-supplied memory tracking callback and optional streaming.
-
Constructor Details
-
FetchPhase
-
-
Method Details
-
execute
Executes the fetch phase without memory checking or streaming.- Parameters:
context- the search contextdocIdsToLoad- document IDs to fetchrankDocs- ranking information
-
execute
public void execute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs, @Nullable IntConsumer memoryChecker) Executes the fetch phase with an optional caller-supplied memory tracking callback and no streaming- Parameters:
context- the search contextdocIdsToLoad- document IDs to fetchrankDocs- ranking informationmemoryChecker- optional callback for memory tracking, may be null
-
execute
public void execute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs, @Nullable IntConsumer memoryChecker, @Nullable FetchPhaseResponseChunk.Writer writer, @Nullable Integer maxInFlightChunks, @Nullable ActionListener<Void> buildListener, ActionListener<Void> listener) Executes the fetch phase with an optional caller-supplied memory tracking callback and optional streaming.When
writerisnull(non-streaming), all hits are accumulated in memory and returned at once. Whenwriteris provided (streaming), hits are emitted in chunks to reduce peak memory usage. In streaming mode, the final completion may be delayed by transport-level acknowledgements, but the fetch build completion is signaled as soon as the fetch work has finished.- Parameters:
context- the search contextdocIdsToLoad- document IDs to fetchrankDocs- ranking informationmemoryChecker- optional callback for memory tracking, may benullwriter- optional chunk writer for streaming mode, may benullbuildListener- optional listener invoked when allSearchHitobjects have been constructed (and, in streaming mode, serialized into chunks and dispatched to the writer). In non-streaming mode this fires immediately after the hits are built, just likelistener. In streaming mode this fires before chunk ACKs arrive, allowing the caller to release shard resources (e.g. close the SearchContext) without waiting for network acknowledgements.listener- final completion listener. In streaming mode this is invoked only after all chunks are ACKed; in non-streaming mode it is invoked immediately after hits are built.- Throws:
TaskCancelledException- if the task is cancelled
-