Class LuceneQueryEvaluator<T extends Vector.Builder>

java.lang.Object
org.elasticsearch.compute.lucene.LuceneQueryEvaluator<T>
All Implemented Interfaces:
Closeable, AutoCloseable, org.elasticsearch.core.Releasable
Direct Known Subclasses:
LuceneQueryExpressionEvaluator, LuceneQueryScoreEvaluator

public abstract class LuceneQueryEvaluator<T extends Vector.Builder> extends Object implements org.elasticsearch.core.Releasable
Base class for evaluating a Lucene query at the compute engine and providing a Block as a result. Subclasses can override methods to decide what type of Block should be returned, and how to add results to it based on documents on the Page matching the query or not. See LuceneQueryExpressionEvaluator for an example of how to use this class and LuceneQueryScoreEvaluator for examples of subclasses that provide different types of scoring results for different ESQL constructs. It's much faster to push queries to the LuceneSourceOperator or the like, but sometimes this isn't possible. So this class is here to save the day.
  • Constructor Details

  • Method Details

    • executeQuery

      public Block executeQuery(Page page)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • scoreMode

      protected abstract org.apache.lucene.search.ScoreMode scoreMode()
      Returns the score mode to use on searches
    • createNoMatchVector

      protected abstract Vector createNoMatchVector(BlockFactory blockFactory, int size)
      Creates a vector where all positions correspond to elements that don't match the query
    • createVectorBuilder

      protected abstract T createVectorBuilder(BlockFactory blockFactory, int size)
      Creates the corresponding vector builder to store the results of evaluating the query
    • appendMatch

      protected abstract void appendMatch(T builder, org.apache.lucene.search.Scorable scorer) throws IOException
      Appends a matching result to a builder created by @link createVectorBuilder}
      Throws:
      IOException
    • appendNoMatch

      protected abstract void appendNoMatch(T builder)
      Appends a non matching result to a builder created by @link createVectorBuilder}