Class ValuesSourceAggregationBuilder<VS extends ValuesSource,​AB extends ValuesSourceAggregationBuilder<VS,​AB>>

    • Constructor Detail

      • ValuesSourceAggregationBuilder

        protected ValuesSourceAggregationBuilder​(java.lang.String name,
                                                 ValuesSourceType valuesSourceType,
                                                 ValueType targetValueType)
      • ValuesSourceAggregationBuilder

        protected ValuesSourceAggregationBuilder​(StreamInput in,
                                                 ValuesSourceType valuesSourceType,
                                                 ValueType targetValueType)
                                          throws java.io.IOException
        Read an aggregation from a stream that has a sensible default for TargetValueType. This should be used by most subclasses. Subclasses needing to maintain backward compatibility to a version that did not serialize TargetValueType should use this constructor, providing the old, constant value for TargetValueType and override serializeTargetValueType(Version) to return true only for versions that support the serialization.
        Throws:
        java.io.IOException
      • ValuesSourceAggregationBuilder

        protected ValuesSourceAggregationBuilder​(StreamInput in,
                                                 ValuesSourceType valuesSourceType)
                                          throws java.io.IOException
        Read an aggregation from a stream that serializes its targetValueType. This should only be used by subclasses that override serializeTargetValueType(Version) to return true.
        Throws:
        java.io.IOException
    • Method Detail

      • 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)
        Should this builder serialize its targetValueType? Defaults to false. All subclasses that override this to true should use the three argument read constructor rather than the four argument version.
        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.
      • valueType

        public AB valueType​(ValueType valueType)
        Sets the ValueType for the value produced by this aggregation
      • valueType

        public ValueType valueType()
        Gets the ValueType for the value produced by this aggregation
      • 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
      • resolveScriptAny

        protected ValuesSourceType resolveScriptAny​(Script script)
        Provide a hook for aggregations to have finer grained control of the ValuesSourceType for script values. This will only be called if the user did not supply a type hint for the script. The script object is provided for reference.
        Parameters:
        script - - The user supplied script
        Returns:
        The ValuesSourceType we expect this script to yield.
      • defaultValueType

        protected ValueType defaultValueType​(Script script)
        Provide a hook for aggregations to have finer grained control of the ValueType for script values. This will only be called if the user did not supply a type hint for the script. The script object is provided for reference
        Parameters:
        script - - the user supplied script
        Returns:
        The ValueType we expect this script to yield