Class 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
  • 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.IOException
      Build an Aggregator for a filters aggregation. If there isn't a parent, there aren't children, and we don't collect "other" buckets then this will a faster FiltersAggregator.FilterByFilter aggregator. Otherwise it'll fall back to a slower aggregator that is FiltersAggregator.Compatible with parent, children, and "other" buckets.
      Throws:
      java.io.IOException
    • canUseFilterByFilter

      public static boolean canUseFilterByFilter​(Aggregator parent, java.lang.String otherBucketKey)
      Can this aggregation be executed using the FiltersAggregator.FilterByFilter? That aggregator is much faster than the fallback FiltersAggregator.Compatible aggregator.
    • 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.IOException
      Build an Aggregator for a filters aggregation if we can collect FiltersAggregator.FilterByFilter, otherwise return null. We can collect filter by filter if there isn't a parent, there aren't children, and we don't collect "other" buckets. Collecting FiltersAggregator.FilterByFilter is generally going to be much faster than the FiltersAggregator.Compatible aggregator.

      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

      public InternalAggregation[] buildAggregations​(long[] owningBucketOrds) throws java.io.IOException
      Description copied from class: Aggregator
      Build the results of this aggregation.
      Specified by:
      buildAggregations in class Aggregator
      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

      public InternalAggregation buildEmptyAggregation()
      Description copied from class: Aggregator
      Build an empty aggregation.
      Specified by:
      buildEmptyAggregation in class Aggregator
    • collectDebugInfo

      public void collectDebugInfo​(java.util.function.BiConsumer<java.lang.String,​java.lang.Object> add)
      Description copied from class: Aggregator
      Collect 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) and XContentBuilder.value(Object). And they'll have an integration test.

      Overrides:
      collectDebugInfo in class Aggregator