Class ExpressionQueryList

java.lang.Object
org.elasticsearch.xpack.esql.enrich.ExpressionQueryList
All Implemented Interfaces:
LookupEnrichQueryGenerator

public class ExpressionQueryList extends Object implements LookupEnrichQueryGenerator
A LookupEnrichQueryGenerator that combines multiple conditions into a single query list. Each query in the resulting query will be a conjunction of all queries from the input lists at the same position. In addition, we support an optional pre-join filter that will be applied to all queries if it is pushable. If the pre-join filter cannot be pushed down to Lucene, it will be ignored. This class is used in the context of a lookup join, where we need to generate a query for each row of the left dataset. The query is then used to fetch the matching rows from the right dataset. The class supports two types of joins: 1. Field-based join: The join conditions are based on the equality of fields from the left and right datasets. It is used for field-based join when the join is on more than one field or there is a preJoinFilter 2. Expression-based join: The join conditions are based on a complex expression that can involve multiple fields and operators.
  • Method Details

    • fieldBasedJoin

      public static ExpressionQueryList fieldBasedJoin(List<QueryList> queryLists, SearchExecutionContext context, PhysicalPlan rightPreJoinPlan, ClusterService clusterService, AliasFilter aliasFilter)
      Creates a new ExpressionQueryList for a field-based join. A field-based join is a join where the join conditions are based on the equality of fields from the left and right datasets. For example | LOOKUP JOIN on field1, field2, field3 The query lists are generated from the join conditions. The pre-join filter is an optional filter that is applied to the right dataset before the join.
    • expressionBasedJoin

      public static ExpressionQueryList expressionBasedJoin(SearchExecutionContext context, PhysicalPlan rightPreJoinPlan, ClusterService clusterService, LookupFromIndexService.TransportRequest request, AliasFilter aliasFilter, Warnings warnings)
      Creates a new ExpressionQueryList for an expression-based join. An expression-based join is a join where the join conditions are based on a complex expression that can involve multiple fields and operators. Example | LOOKUP JOIN on left_field > right_field AND left_field2 == right_field2 The query lists are generated from the join conditions. The pre-join filter is an optional filter that is applied to the right dataset before the join.
    • getQuery

      public org.apache.lucene.search.Query getQuery(int position)
      Returns the query at the given position. The query is a conjunction of all queries from the input lists at the same position. If a pre-join filter exists, it is also added to the query.
      Specified by:
      getQuery in interface LookupEnrichQueryGenerator
      Parameters:
      position - The position of the query to return.
      Returns:
      The query at the given position, or null if any of the match fields are null.
    • getPositionCount

      public int getPositionCount()
      Returns the number of positions in the query list. The number of positions is the same for all query lists.
      Specified by:
      getPositionCount in interface LookupEnrichQueryGenerator
      Returns:
      The number of positions in the query list.
      Throws:
      IllegalArgumentException - if the query lists have different position counts.