Class AbstractLookupService<R extends org.elasticsearch.xpack.esql.enrich.AbstractLookupService.Request,T extends org.elasticsearch.xpack.esql.enrich.AbstractLookupService.TransportRequest>
- Direct Known Subclasses:
EnrichLookupService,LookupFromIndexService
AbstractLookupService performs a LEFT JOIN for a given input
page against another index that must have only a single
shard.
This registers a TransportRequestHandler so we can handle requests
to join data that isn't local to the node, but it is much faster if the
data is already local.
The join process spawns a Driver per incoming page which runs in
two, three or four stages:
Stage 1: Finding matching document IDs for the input page. This stage is done
by the EnrichQuerySourceOperator. The output page of this stage is
represented as [DocVector, IntBlock: positions of the input terms].
Stage 2: Extracting field values for the matched document IDs. The output page
is represented as
[DocVector, IntBlock: positions, Block: field1, Block: field2,...].
Stage 3: Optionally the BulkLookupMvFilterOperator removes false-positive
multivalue matches when the BulkKeywordLookup optimization is active.
Stage 4: Optionally this combines the extracted values based on positions and filling
nulls for positions without matches. This is done by MergePositionsOperator.
The output page is represented as [Block: field1, Block: field2,...].
The Page.getPositionCount() of the output Page is equal to the
Page.getPositionCount() of the input page. In other words - it returns
the same number of rows that it was sent no matter how many documents match.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAbstractLookupServiceuses this to power the queries and field loading that it needs to perform to actually do the lookup.static interfaceCreate aAbstractLookupService.LookupShardContextfor a locally allocatedShardId. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BigArraysprotected final BlockFactoryprotected final ClusterServiceprotected final Executorprotected final IndicesServiceprotected final LocalCircuitBreaker.SizeSettingsstatic final ReferenceAttributeRepresents an integer column that corresponds to the positions of the page that we perform the lookup for.protected final AbstractLookupService.LookupShardContextFactoryprotected final booleanShould outputpagesbe combined into a single resulting page? If this istruewe'll run aMergePositionsOperatorto merge all output Pages into a single result, merging each found document into one row per input row, squashing the fields into multivalued fields.protected final PlannerSettings.Holderprotected final ProjectResolverprotected final TransportService -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponsecreateLookupResponse(List<Page> resultPages, BlockFactory blockFactory) Build the response.protected PagecreateNullResponse(int positionCount, List<NamedExpression> extractFields) protected voiddoLookup(T request, CancellableTask task, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> listener) static StringextractFieldName(NamedExpression extractField) final voidlookupAsync(R request, DiscoveryNode targetNode, CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> outListener) Perform the actual lookup using an explicit target node.final voidlookupAsync(R request, CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> outListener) Perform the actual lookup, returning the fullAbstractLookupService.LookupResponse.protected abstract LookupEnrichQueryGeneratorqueryList(T request, SearchExecutionContext context, AliasFilter aliasFilter, Warnings warnings) Build a list of queries to perform inside the actual lookup.protected abstract org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponsereadLookupResponse(StreamInput in, BlockFactory blockFactory) Read the response from aStreamInput.protected final voidrespondWithPages(ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> listener, List<Page> pages) Helper to create a LookupResponse from pages and send it to the listener.protected voidsendChildRequest(CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> delegate, DiscoveryNode targetNode, T transportRequest) protected static QueryListtermQueryList(MappedFieldType field, AliasFilter aliasFilter, int channelOffset, DataType inputDataType) protected abstract TtransportRequest(R request, ShardId shardId) Convert a request as sent tolookupAsync(R, org.elasticsearch.tasks.CancellableTask, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse>)into a transport request after preflight checks have been performed.
-
Field Details
-
LOOKUP_POSITIONS_FIELD
Represents an integer column that corresponds to the positions of the page that we perform the lookup for. -
clusterService
-
indicesService
-
lookupShardContextFactory
-
transportService
-
executor
-
blockFactory
-
bigArrays
-
localBreakerSettings
-
projectResolver
-
plannerSettings
-
mergePages
protected final boolean mergePagesShould outputpagesbe combined into a single resulting page? If this istruewe'll run aMergePositionsOperatorto merge all output Pages into a single result, merging each found document into one row per input row, squashing the fields into multivalued fields. If this isfalsethen we'll skip this step, and it's up to the caller to figure out what to do with aListof resulting pages.
-
-
Method Details
-
getThreadContext
-
transportRequest
Convert a request as sent tolookupAsync(R, org.elasticsearch.tasks.CancellableTask, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse>)into a transport request after preflight checks have been performed. -
queryList
protected abstract LookupEnrichQueryGenerator queryList(T request, SearchExecutionContext context, AliasFilter aliasFilter, Warnings warnings) Build a list of queries to perform inside the actual lookup. -
createLookupResponse
protected abstract org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse createLookupResponse(List<Page> resultPages, BlockFactory blockFactory) Build the response. -
respondWithPages
protected final void respondWithPages(ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> listener, List<Page> pages) Helper to create a LookupResponse from pages and send it to the listener. The response is released after sending viaActionListener.respondAndRelease(org.elasticsearch.action.ActionListener<R>, R). -
readLookupResponse
protected abstract org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse readLookupResponse(StreamInput in, BlockFactory blockFactory) throws IOException Read the response from aStreamInput.- Throws:
IOException
-
termQueryList
protected static QueryList termQueryList(MappedFieldType field, AliasFilter aliasFilter, int channelOffset, DataType inputDataType) -
lookupAsync
public final void lookupAsync(R request, CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> outListener) Perform the actual lookup, returning the fullAbstractLookupService.LookupResponse. Callers can access pages viaAbstractLookupService.LookupResponse.takePages()and must callTransportMessage.decRef()when done. This method determines the target node internally via shard routing. -
lookupAsync
public final void lookupAsync(R request, DiscoveryNode targetNode, CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> outListener) Perform the actual lookup using an explicit target node. Use this overload when the caller has already determined which node should handle the request, to avoid inconsistent node selection when replicas exist. -
sendChildRequest
protected void sendChildRequest(CancellableTask parentTask, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> delegate, DiscoveryNode targetNode, T transportRequest) -
doLookup
protected void doLookup(T request, CancellableTask task, ActionListener<org.elasticsearch.xpack.esql.enrich.AbstractLookupService.LookupResponse> listener) -
getBreaker
-
getExecutor
-
extractFieldName
-
createNullResponse
-