Class QueryToFilterAdapter<Q extends org.apache.lucene.search.Query>

java.lang.Object
org.elasticsearch.search.aggregations.bucket.filter.QueryToFilterAdapter<Q>

public class QueryToFilterAdapter<Q extends org.apache.lucene.search.Query> extends Object
Adapts a Lucene Query to the behaviors used be the FiltersAggregator. In general we try to delegate to Query when we don't have a special optimization.
  • Method Summary

    Modifier and Type
    Method
    Description
    build(org.apache.lucene.search.IndexSearcher searcher, String key, org.apache.lucene.search.Query query)
    Build a filter for the query against the provided searcher.
    protected final boolean
    countCanUseMetadata(org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator.Counter counter, org.apache.lucene.util.Bits live)
    Would using index metadata like IndexReader.docFreq(org.apache.lucene.index.Term) or IndexReader.maxDoc() to count the number of matching documents produce the same answer as collecting the results with a sequence like searcher.collect(counter); return counter.readAndReset();?
    boolean
    Is this an inefficient union of the top level query with the filter? If the top level query if complex we can't efficiently merge it with the filter.
    final String
    key()
    Key for this filter.
    protected final org.apache.lucene.search.IndexSearcher
    Searcher that this filter is targeting.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • build

      public static QueryToFilterAdapter<?> build(org.apache.lucene.search.IndexSearcher searcher, String key, org.apache.lucene.search.Query query) throws IOException
      Build a filter for the query against the provided searcher.

      Note: This method rewrites the query against the IndexSearcher

      Throws:
      IOException
    • isInefficientUnion

      public boolean isInefficientUnion()
      Is this an inefficient union of the top level query with the filter? If the top level query if complex we can't efficiently merge it with the filter. If we can't do that it is likely faster to just run the "native" aggregation implementation rather than go filter by filter.
    • key

      public final String key()
      Key for this filter.
    • searcher

      protected final org.apache.lucene.search.IndexSearcher searcher()
      Searcher that this filter is targeting.
    • countCanUseMetadata

      protected final boolean countCanUseMetadata(org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator.Counter counter, org.apache.lucene.util.Bits live)
      Would using index metadata like IndexReader.docFreq(org.apache.lucene.index.Term) or IndexReader.maxDoc() to count the number of matching documents produce the same answer as collecting the results with a sequence like searcher.collect(counter); return counter.readAndReset();?