Module org.elasticsearch.server
Class IpPrefixAggregationBuilder
java.lang.Object
org.elasticsearch.search.aggregations.AggregationBuilder
org.elasticsearch.search.aggregations.AbstractAggregationBuilder<IpPrefixAggregationBuilder>
org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
org.elasticsearch.search.aggregations.bucket.prefix.IpPrefixAggregationBuilder
- All Implemented Interfaces:
NamedWriteable,VersionedNamedWriteable,Writeable,Rewriteable<AggregationBuilder>,BaseAggregationBuilder,ToXContent,ToXContentFragment
public class IpPrefixAggregationBuilder
extends ValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
A builder for IP prefix aggregations. This builder can operate with both IPv4 and IPv6 fields.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
ValuesSourceAggregationBuilder.LeafOnly<AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.MetricsAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.SingleMetricAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>>Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
AggregationBuilder.BucketCardinality, AggregationBuilder.CommonFieldsNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final Stringstatic final ObjectParser<IpPrefixAggregationBuilder, String> static final ParseFieldstatic final ValuesSourceRegistry.RegistryKey<IpPrefixAggregationSupplier> Fields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metadataFields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
DEFAULT_PREALLOCATION, factoriesBuilder, nameFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a new builder with the given name.Read from a stream, for internal use only.protectedIpPrefixAggregationBuilder(IpPrefixAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) -
Method Summary
Modifier and TypeMethodDescriptionappendPrefixLength(boolean appendPrefixLength) Set the appendPrefixLength on this builder, and return the builder so that calls can be chained.A rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.protected ValuesSourceTypeAggregations should use this method to define aValuesSourceTypeof last resort.protected XContentBuilderdoXContentBody(XContentBuilder builder, ToXContent.Params params) booleanstatic org.apache.lucene.util.BytesRefextractNetmask(int prefixLength, boolean isIpv6) The minimal version of the recipient this object can be sent to.getType()The name of the type of aggregation built by this builder.inthashCode()protected ValuesSourceAggregatorFactoryinnerBuild(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) protected voidinnerWriteTo(StreamOutput out) Write subclass's state to the stream.isIpv6(boolean isIpv6) Set the isIpv6 on this builder, and return the builder so that calls can be chained.keyed(boolean keyed) Set the keyed on this builder, and return the builder so that calls can be chained.minDocCount(long minDocCount) Set the minDocCount on this builder, and return the builder so that calls can be chained.prefixLength(int prefixLength) Set the prefixLength on this builder, and return the builder so that calls can be chained.static voidprotected AggregationBuildershallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetadata.Methods inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
declareFields, declareFields, doBuild, doWriteTo, field, field, format, format, internalXContent, missing, resolveConfig, script, script, serializeTargetValueType, timeZone, timeZone, userValueTypeHint, userValueTypeHintMethods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetadata, getWriteableName, setMetadata, subAggregation, subAggregation, subAggregations, toXContent, writeToMethods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
buildPipelineTree, bytesToPreallocate, deepCopy, doRewrite, getName, getOutputFieldNames, getPipelineAggregations, getQuery, getSubAggregations, isInSortOrderExecutionRequired, rewrite, supportsParallelCollection, supportsSampling, toString, validateSequentiallyOrdered, validateSequentiallyOrderedWithoutGapsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragmentMethods inherited from interface org.elasticsearch.common.io.stream.VersionedNamedWriteable
supportsVersion
-
Field Details
-
NAME
- See Also:
-
REGISTRY_KEY
-
PARSER
-
PREFIX_LENGTH_FIELD
-
IS_IPV6_FIELD
-
APPEND_PREFIX_LENGTH_FIELD
-
MIN_DOC_COUNT_FIELD
-
KEYED_FIELD
-
-
Constructor Details
-
IpPrefixAggregationBuilder
Read from a stream, for internal use only.- Throws:
IOException
-
IpPrefixAggregationBuilder
Create a new builder with the given name. -
IpPrefixAggregationBuilder
protected IpPrefixAggregationBuilder(IpPrefixAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata)
-
-
Method Details
-
registerAggregators
-
minDocCount
Set the minDocCount on this builder, and return the builder so that calls can be chained. -
prefixLength
Set the prefixLength on this builder, and return the builder so that calls can be chained.- Throws:
IllegalArgumentException- if prefixLength is negative.
-
isIpv6
Set the isIpv6 on this builder, and return the builder so that calls can be chained. -
appendPrefixLength
Set the appendPrefixLength on this builder, and return the builder so that calls can be chained. -
keyed
Set the keyed on this builder, and return the builder so that calls can be chained. -
shallowCopy
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Description copied from class:AggregationBuilderCreate a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetadata.- Specified by:
shallowCopyin classAggregationBuilder
-
bucketCardinality
Description copied from class:AggregationBuilderA rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.- Specified by:
bucketCardinalityin classAggregationBuilder
-
getType
Description copied from interface:BaseAggregationBuilderThe name of the type of aggregation built by this builder. -
innerWriteTo
Description copied from class:ValuesSourceAggregationBuilderWrite subclass's state to the stream.- Specified by:
innerWriteToin classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>- Throws:
IOException
-
defaultValueSourceType
Description copied from class:ValuesSourceAggregationBuilderAggregations should use this method to define aValuesSourceTypeof 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.- Specified by:
defaultValueSourceTypein classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>- Returns:
- The CoreValuesSourceType we expect this script to yield.
-
innerBuild
protected ValuesSourceAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException - Specified by:
innerBuildin classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>- Throws:
IOException
-
extractNetmask
public static org.apache.lucene.util.BytesRef extractNetmask(int prefixLength, boolean isIpv6) - Parameters:
prefixLength- the network prefix length which defines the size of the network.isIpv6- true for an IPv6 netmask, false for an IPv4 netmask.- Returns:
- a 16-bytes representation of the subnet with 1s identifying the network part and 0s identifying the host part.
- Throws:
IllegalArgumentException- if prefixLength is not in range [0, 128] for an IPv6 network, or is not in range [0, 32] for an IPv4 network.
-
doXContentBody
protected XContentBuilder doXContentBody(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
doXContentBodyin classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>- Throws:
IOException
-
equals
- Overrides:
equalsin classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
-
hashCode
public int hashCode()- Overrides:
hashCodein classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
-
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to. SeeVersionedNamedWriteable.supportsVersion(TransportVersion)for the default serialization check.
-