Class ValuesSourceAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>

java.lang.Object
org.elasticsearch.search.aggregations.AggregationBuilder
org.elasticsearch.search.aggregations.AbstractAggregationBuilder<AB>
org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<AB>
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment, Rewriteable<AggregationBuilder>, BaseAggregationBuilder
Direct Known Subclasses:
AbstractRangeBuilder, AutoDateHistogramAggregationBuilder, DateHistogramAggregationBuilder, DiversifiedAggregationBuilder, GeoBoundsAggregationBuilder, GeoDistanceAggregationBuilder, GeoGridAggregationBuilder, HistogramAggregationBuilder, IpRangeAggregationBuilder, MissingAggregationBuilder, RareTermsAggregationBuilder, SignificantTermsAggregationBuilder, TermsAggregationBuilder, ValuesSourceAggregationBuilder.LeafOnly, VariableWidthHistogramAggregationBuilder

public abstract class ValuesSourceAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>
extends AbstractAggregationBuilder<AB>
  • Field Details

  • Constructor Details

    • ValuesSourceAggregationBuilder

      protected ValuesSourceAggregationBuilder​(java.lang.String name)
    • ValuesSourceAggregationBuilder

      protected ValuesSourceAggregationBuilder​(ValuesSourceAggregationBuilder<AB> clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,​java.lang.Object> metadata)
    • ValuesSourceAggregationBuilder

      protected ValuesSourceAggregationBuilder​(StreamInput in) throws java.io.IOException
      Read from a stream.
      Throws:
      java.io.IOException
  • Method Details

    • declareFields

      public static <T> void declareFields​(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends ValuesSourceAggregationBuilder<?>,​T> objectParser, boolean scriptable, boolean formattable, boolean timezoneAware)
    • declareFields

      public static <T> void declareFields​(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends ValuesSourceAggregationBuilder<?>,​T> objectParser, boolean scriptable, boolean formattable, boolean timezoneAware, boolean fieldRequired)
    • doWriteTo

      protected final void doWriteTo​(StreamOutput out) throws java.io.IOException
      Specified by:
      doWriteTo in class AbstractAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>
      Throws:
      java.io.IOException
    • innerWriteTo

      protected abstract void innerWriteTo​(StreamOutput out) throws java.io.IOException
      Write subclass's state to the stream.
      Throws:
      java.io.IOException
    • serializeTargetValueType

      protected boolean serializeTargetValueType​(Version version)
      DO NOT OVERRIDE THIS!

      This method only exists for legacy support. No new aggregations need this, nor should they override it.

      Parameters:
      version - For backwards compatibility, subclasses can change behavior based on the version
    • field

      public AB field​(java.lang.String field)
      Sets the field to use for this aggregation.
    • field

      public java.lang.String field()
      Gets the field to use for this aggregation.
    • script

      public AB script​(Script script)
      Sets the script to use for this aggregation.
    • script

      public Script script()
      Gets the script to use for this aggregation.
    • userValueTypeHint

      public AB userValueTypeHint​(ValueType valueType)
      This setter should only be used during parsing, to set the userValueTypeHint. This is information the user provides in the json query to indicate the output type of a script or the type of the 'missing' replacement value.
      Parameters:
      valueType - - The parsed ValueType based on the string the user specified
      Returns:
      - The modified builder instance, for chaining.
    • userValueTypeHint

      public ValueType userValueTypeHint()
    • format

      public AB format​(java.lang.String format)
      Sets the format to use for the output of the aggregation.
    • format

      public java.lang.String format()
      Gets the format to use for the output of the aggregation.
    • missing

      public AB missing​(java.lang.Object missing)
      Sets the value to use when the aggregation finds a missing value in a document
    • missing

      public java.lang.Object missing()
      Gets the value to use when the aggregation finds a missing value in a document
    • timeZone

      public AB timeZone​(java.time.ZoneId timeZone)
      Sets the time zone to use for this aggregation
    • timeZone

      public java.time.ZoneId timeZone()
      Gets the time zone to use for this aggregation
    • doBuild

      protected final ValuesSourceAggregatorFactory doBuild​(AggregationContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws java.io.IOException
      Specified by:
      doBuild in class AbstractAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>
      Throws:
      java.io.IOException
    • getRegistryKey

      protected abstract ValuesSourceRegistry.RegistryKey<?> getRegistryKey()
    • defaultValueSourceType

      protected abstract ValuesSourceType defaultValueSourceType()
      Aggregations should use this method to define a ValuesSourceType of last resort. This will only be used when the resolver can't find a field and the user hasn't provided a value type hint.
      Returns:
      The CoreValuesSourceType we expect this script to yield.
    • resolveConfig

      protected ValuesSourceConfig resolveConfig​(AggregationContext context)
      Aggregations should override this if they need non-standard logic for resolving where to get values from. For example, join aggregations (like Parent and Child) ask the user to specify one side of the join and then look up the other field to read values from.

      The default implementation just uses the field and/or script the user provided.

      Returns:
      A ValuesSourceConfig configured based on the parsed field and/or script.
    • innerBuild

      protected abstract ValuesSourceAggregatorFactory innerBuild​(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws java.io.IOException
      Throws:
      java.io.IOException
    • internalXContent

      public final org.elasticsearch.common.xcontent.XContentBuilder internalXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      internalXContent in class AbstractAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>
      Throws:
      java.io.IOException
    • doXContentBody

      protected abstract org.elasticsearch.common.xcontent.XContentBuilder doXContentBody​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Throws:
      java.io.IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class AbstractAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>