Class QueryToFilterAdapter<Q extends org.apache.lucene.search.Query>
java.lang.Object
org.elasticsearch.search.aggregations.bucket.filter.QueryToFilterAdapter<Q>
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 TypeMethodDescriptionstatic QueryToFilterAdapter<?>
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 likeIndexReader.docFreq(org.apache.lucene.index.Term)
orIndexReader.maxDoc()
to count the number of matching documents produce the same answer as collecting the results with a sequence likesearcher.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()
Searcher that this filter is targeting.
-
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
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 likeIndexReader.docFreq(org.apache.lucene.index.Term)
orIndexReader.maxDoc()
to count the number of matching documents produce the same answer as collecting the results with a sequence likesearcher.collect(counter); return counter.readAndReset();
?
-