Class AutoPrefilteringScope

java.lang.Object
org.elasticsearch.index.query.support.AutoPrefilteringScope
All Implemented Interfaces:
Closeable, AutoCloseable, Releasable

public final class AutoPrefilteringScope extends Object implements Releasable
Keeps track of queries to be used as prefilters. During QueryBuilder.toQuery(SearchExecutionContext), each query pushes queries to be used as prefilters to the AutoPrefilteringScope. Queries that need to apply prefilters can fetch them by calling getPrefilters(). The scope is implemented as a stack Deque of lists of prefilters. As we move down the query tree, each query may push a list of prefilters. A query that consumes prefilters fetches a flattened list of all prefilters in scope via getPrefilters(). When the query leaves the scope, pop() should be called to remove the latest list of prefilters from the stack. This way queries in other query tree branches will not fetch irrelevant prefilters.
  • Constructor Details

    • AutoPrefilteringScope

      public AutoPrefilteringScope()
  • Method Details

    • push

      public void push(List<QueryBuilder> prefilters)
      Pushes a list of prefilters to the scope.
    • pop

      public void pop()
      Removes the latest list of prefilters from the scope.
    • getPrefilters

      public List<QueryBuilder> getPrefilters()
      Returns all prefilters in scope.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Releasable