Class SingleValueQuery

java.lang.Object
org.elasticsearch.xpack.esql.core.querydsl.query.Query
org.elasticsearch.xpack.esql.querydsl.query.SingleValueQuery

public class SingleValueQuery extends Query
Lucene query that wraps another query and only selects documents that match the wrapped query and have a single field value.

This allows us to wrap regular lucene queries to have ESQL style semantics which will allow us to continue to push expressions to Lucene.

We could have chosen not to wrap the lucene query and instead double check the results after they are loaded. That could be faster in some cases, but for now we're going to always wrap so we can always push. When we find cases where double checking is better we'll try that.

NOTE: This will only work with text fields.

  • Field Details

  • Constructor Details

    • SingleValueQuery

      public SingleValueQuery(Query next, String field, boolean useSyntheticSourceDelegate)
      Build.
      Parameters:
      next - the query whose documents we should use for single-valued fields
      field - the name of the field whose values to check
      useSyntheticSourceDelegate - Should we check the field's synthetic source delegate (true) or it's values itself? If the field is a text field we often want to use its delegate.
    • SingleValueQuery

      public SingleValueQuery(Query next, String field, SingleValueQuery.UseSyntheticSourceDelegate useSyntheticSourceDelegate)
  • Method Details

    • asBuilder

      protected SingleValueQuery.AbstractBuilder asBuilder()
      Description copied from class: Query
      Used internally to convert to retrieve a QueryBuilder by queries.
      Specified by:
      asBuilder in class Query
    • innerToString

      protected String innerToString()
      Description copied from class: Query
      Used by Query.toString() to produce a pretty string.
      Specified by:
      innerToString in class Query
    • negate

      public SingleValueQuery negate(Source source)
      Description copied from class: Query
      Negate this query, returning a query that includes documents that would return false when running the represented operation. The default implementation just returns a NotQuery wrapping this because most queries don't model underlying operations that can return null. Queries that model expressions that can return null must make sure all documents that would return null are still excluded from the match.
      Overrides:
      negate in class Query
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Query
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Query
    • containsPlan

      public boolean containsPlan()
      Description copied from class: Query
      Does the result of calling Query.asBuilder() need the plan to serialize itself?
      Specified by:
      containsPlan in class Query