Interface TranslationAware

All Known Subinterfaces:
TranslationAware.SingleValueTranslationAware
All Known Implementing Classes:
And, BinaryLogic, CIDRMatch, EndsWith, Equals, EsqlBinaryComparison, FullTextFunction, GreaterThan, GreaterThanOrEqual, In, InsensitiveBinaryComparison, InsensitiveEquals, IsNotNull, IsNull, Knn, Kql, LessThan, LessThanOrEqual, Match, MatchOperator, MatchPhrase, MultiMatchQueryPredicate, Not, NotEquals, Or, QueryString, Range, RLike, SpatialContains, SpatialDisjoint, SpatialIntersects, SpatialRelatesFunction, SpatialWithin, StartsWith, Term, WildcardLike, WildcardLikeList

public interface TranslationAware
Expressions implementing this interface are asked provide an Elasticsearch/Lucene query as part of the data node optimizations.
  • Method Details

    • translatable

      TranslationAware.Translatable translatable(LucenePushdownPredicates pushdownPredicates)
      Can this instance be translated or not? Usually checks whether the expression arguments are actual fields that exist in Lucene. See TranslationAware.Translatable for precisely what can be signaled from this method.
    • translatable

      static TranslationAware.Translatable translatable(Expression exp, LucenePushdownPredicates lucenePushdownPredicates)
      Is an Expression translatable?
    • asQuery

      Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler)
      Translates the implementing expression into a Query. If during translation a child needs to be translated first, the handler needs to be used even if the child implements this interface as well. This is to ensure that the child is wrapped in a SingleValueQuery if necessary.

      So use this:

      Query childQuery = handler.asQuery(child);

      and not this:

      Query childQuery = child.asQuery(handler);

    • asLuceneQuery

      default org.apache.lucene.search.Query asLuceneQuery(MappedFieldType fieldType, org.apache.lucene.search.MultiTermQuery.RewriteMethod constantScoreRewrite, SearchExecutionContext context)
      Translates this expression into a Lucene Query.

      Implementations should use the provided field type, rewrite method, and search execution context to construct an appropriate Lucene query for this expression. By default, this method throws UnsupportedOperationException; override it in subclasses that support Lucene query translation.