Class FiltersAggregator
java.lang.Object
org.elasticsearch.search.aggregations.BucketCollector
org.elasticsearch.search.aggregations.Aggregator
org.elasticsearch.search.aggregations.AggregatorBase
org.elasticsearch.search.aggregations.bucket.BucketsAggregator
org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,org.apache.lucene.search.Collector,org.elasticsearch.common.lease.Releasable
- Direct Known Subclasses:
FiltersAggregator.FilterByFilter
public abstract class FiltersAggregator extends BucketsAggregator
Aggregator for
filters. There are two known subclasses,
FiltersAggregator.FilterByFilter which is fast but only works in some cases and
FiltersAggregator.Compatible which works in all cases.
build(java.lang.String, org.elasticsearch.search.aggregations.AggregatorFactories, java.util.List<org.elasticsearch.search.aggregations.bucket.filter.QueryToFilterAdapter<?>>, boolean, java.lang.String, org.elasticsearch.search.aggregations.support.AggregationContext, org.elasticsearch.search.aggregations.Aggregator, org.elasticsearch.search.aggregations.CardinalityUpperBound, java.util.Map<java.lang.String, java.lang.Object>) will build the fastest version that
works with the configuration.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFiltersAggregator.FilterByFilterCollects results by running each filter against the searcher and doesn't build anyLeafBucketCollectors which is generally faster thanFiltersAggregator.Compatiblebut doesn't support when there is a parent aggregator or any child aggregators.static classFiltersAggregator.KeyedFilterNested classes/interfaces inherited from class org.elasticsearch.search.aggregations.bucket.BucketsAggregator
BucketsAggregator.BucketBuilderForFixedCount<B>, BucketsAggregator.BucketBuilderForVariable<B>, BucketsAggregator.ResultBuilderForVariable<B>, BucketsAggregator.SingleBucketResultBuilderNested classes/interfaces inherited from class org.elasticsearch.search.aggregations.Aggregator
Aggregator.BucketComparator, Aggregator.Parser, Aggregator.SubAggCollectionMode -
Field Summary
Fields Modifier and Type Field Description static org.elasticsearch.common.ParseFieldFILTERS_FIELDstatic org.elasticsearch.common.ParseFieldOTHER_BUCKET_FIELDstatic org.elasticsearch.common.ParseFieldOTHER_BUCKET_KEY_FIELDprotected java.lang.StringotherBucketKeyFields inherited from class org.elasticsearch.search.aggregations.bucket.BucketsAggregator
docCountProviderFields inherited from class org.elasticsearch.search.aggregations.AggregatorBase
collectableSubAggregators, DEFAULT_WEIGHT, name, parent, subAggregatorsFields inherited from class org.elasticsearch.search.aggregations.BucketCollector
NO_OP_COLLECTOR -
Method Summary
Modifier and Type Method Description static FiltersAggregatorbuild(java.lang.String name, AggregatorFactories factories, java.util.List<QueryToFilterAdapter<?>> filters, boolean keyed, java.lang.String otherBucketKey, AggregationContext context, Aggregator parent, CardinalityUpperBound cardinality, java.util.Map<java.lang.String,java.lang.Object> metadata)Build anAggregatorfor afiltersaggregation.InternalAggregation[]buildAggregations(long[] owningBucketOrds)Build the results of this aggregation.InternalAggregationbuildEmptyAggregation()Build an empty aggregation.static FiltersAggregator.FilterByFilterbuildFilterByFilter(java.lang.String name, AggregatorFactories factories, java.util.List<QueryToFilterAdapter<?>> filters, boolean keyed, java.lang.String otherBucketKey, AggregationContext context, Aggregator parent, CardinalityUpperBound cardinality, java.util.Map<java.lang.String,java.lang.Object> metadata)Build anAggregatorfor afiltersaggregation if we can collectFiltersAggregator.FilterByFilter, otherwise returnnull.static booleancanUseFilterByFilter(Aggregator parent, java.lang.String otherBucketKey)Can this aggregation be executed using theFiltersAggregator.FilterByFilter? That aggregator is much faster than the fallbackFiltersAggregator.Compatibleaggregator.voidcollectDebugInfo(java.util.function.BiConsumer<java.lang.String,java.lang.Object> add)Collect debug information to add to the profiling results.Methods inherited from class org.elasticsearch.search.aggregations.bucket.BucketsAggregator
bucketComparator, bucketDocCount, buildAggregationsForFixedBucketCount, buildAggregationsForSingleBucket, buildAggregationsForVariableBuckets, buildSubAggsForAllBuckets, buildSubAggsForBuckets, buildSubAggsForBuckets, close, collectBucket, collectExistingBucket, descendsFromGlobalAggregator, getDocCounts, grow, incrementBucketDocCount, maxBucketOrd, preGetSubLeafCollectors, prepareSubAggs, resolveSortPath, rewriteBucketsMethods inherited from class org.elasticsearch.search.aggregations.AggregatorBase
addRequestCircuitBreakerBytes, bigArrays, buildEmptySubAggregations, doClose, doPostCollection, doPreCollection, getLeafCollector, getLeafCollector, metadata, name, parent, pointReaderIfAvailable, postCollection, preCollection, scoreMode, searcher, subAggregator, subAggregators, topLevelQuery, toStringMethods inherited from class org.elasticsearch.search.aggregations.Aggregator
buildTopLevel, resolveSortPathOnValidAggMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
FILTERS_FIELD
public static final org.elasticsearch.common.ParseField FILTERS_FIELD -
OTHER_BUCKET_FIELD
public static final org.elasticsearch.common.ParseField OTHER_BUCKET_FIELD -
OTHER_BUCKET_KEY_FIELD
public static final org.elasticsearch.common.ParseField OTHER_BUCKET_KEY_FIELD -
otherBucketKey
protected final java.lang.String otherBucketKey
-
-
Method Details
-
build
public static FiltersAggregator build(java.lang.String name, AggregatorFactories factories, java.util.List<QueryToFilterAdapter<?>> filters, boolean keyed, java.lang.String otherBucketKey, AggregationContext context, Aggregator parent, CardinalityUpperBound cardinality, java.util.Map<java.lang.String,java.lang.Object> metadata) throws java.io.IOExceptionBuild anAggregatorfor afiltersaggregation. If there isn't a parent, there aren't children, and we don't collect "other" buckets then this will a fasterFiltersAggregator.FilterByFilteraggregator. Otherwise it'll fall back to a slower aggregator that isFiltersAggregator.Compatiblewith parent, children, and "other" buckets.- Throws:
java.io.IOException
-
canUseFilterByFilter
Can this aggregation be executed using theFiltersAggregator.FilterByFilter? That aggregator is much faster than the fallbackFiltersAggregator.Compatibleaggregator. -
buildFilterByFilter
public static FiltersAggregator.FilterByFilter buildFilterByFilter(java.lang.String name, AggregatorFactories factories, java.util.List<QueryToFilterAdapter<?>> filters, boolean keyed, java.lang.String otherBucketKey, AggregationContext context, Aggregator parent, CardinalityUpperBound cardinality, java.util.Map<java.lang.String,java.lang.Object> metadata) throws java.io.IOExceptionBuild anAggregatorfor afiltersaggregation if we can collectFiltersAggregator.FilterByFilter, otherwise returnnull. We can collect filter by filter if there isn't a parent, there aren't children, and we don't collect "other" buckets. CollectingFiltersAggregator.FilterByFilteris generally going to be much faster than theFiltersAggregator.Compatibleaggregator.Important: This doesn't properly handle sub-aggregators that need scores so callers must check
#scoreMode()and not use this collector if it need scores.- Throws:
java.io.IOException
-
buildAggregations
Description copied from class:AggregatorBuild the results of this aggregation.- Specified by:
buildAggregationsin classAggregator- Parameters:
owningBucketOrds- the ordinals of the buckets that we want to collect from this aggregation- Returns:
- the results for each ordinal, in the same order as the array of ordinals
- Throws:
java.io.IOException
-
buildEmptyAggregation
Description copied from class:AggregatorBuild an empty aggregation.- Specified by:
buildEmptyAggregationin classAggregator
-
collectDebugInfo
public void collectDebugInfo(java.util.function.BiConsumer<java.lang.String,java.lang.Object> add)Description copied from class:AggregatorCollect debug information to add to the profiling results. This will only be called if the aggregation is being profiled.Well behaved implementations will always call the superclass implementation just in case it has something interesting. They will also only add objects which can be serialized with
StreamOutput.writeGenericValue(Object)andXContentBuilder.value(Object). And they'll have an integration test.- Overrides:
collectDebugInfoin classAggregator
-