Class IpPrefixAggregationBuilder
java.lang.Object
org.elasticsearch.search.aggregations.AggregationBuilder
org.elasticsearch.search.aggregations.AbstractAggregationBuilder<AB>
org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
org.elasticsearch.search.aggregations.bucket.prefix.IpPrefixAggregationBuilder
- All Implemented Interfaces:
NamedWriteable
,VersionedNamedWriteable
,Writeable
,Rewriteable<AggregationBuilder>
,BaseAggregationBuilder
,org.elasticsearch.xcontent.ToXContent
,org.elasticsearch.xcontent.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<VS extends ValuesSource,
AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.MetricsAggregationBuilder<VS extends ValuesSource, AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.SingleMetricAggregationBuilder<VS extends ValuesSource, AB extends ValuesSourceAggregationBuilder<AB>> Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
AggregationBuilder.BucketCardinality, AggregationBuilder.CommonFields
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.elasticsearch.xcontent.ParseField
static final org.elasticsearch.xcontent.ParseField
static final org.elasticsearch.xcontent.ParseField
static final org.elasticsearch.xcontent.ParseField
static final String
static final org.elasticsearch.xcontent.ObjectParser<IpPrefixAggregationBuilder,
String> static final org.elasticsearch.xcontent.ParseField
static final ValuesSourceRegistry.RegistryKey<IpPrefixAggregationSupplier>
Fields inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
config
Fields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metadata
Fields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
DEFAULT_PREALLOCATION, factoriesBuilder, name
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionCreate a new builder with the given name.Read from a stream, for internal use only.protected
IpPrefixAggregationBuilder
(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 thatAggregator
s built by this builder will contain per owning parent bucket.protected ValuesSourceType
Aggregations should use this method to define aValuesSourceType
of last resort.protected org.elasticsearch.xcontent.XContentBuilder
doXContentBody
(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) boolean
static org.apache.lucene.util.BytesRef
extractNetmask
(int prefixLength, boolean isIpv6) protected ValuesSourceRegistry.RegistryKey<?>
getType()
The name of the type of aggregation built by this builder.int
hashCode()
protected ValuesSourceAggregatorFactory
innerBuild
(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) protected void
innerWriteTo
(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 void
protected AggregationBuilder
shallowCopy
(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetadata
.Methods inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
declareFields, declareFields, doBuild, doWriteTo, field, field, format, format, internalXContent, missing, missing, resolveConfig, script, script, serializeTargetValueType, timeZone, timeZone, userValueTypeHint, userValueTypeHint
Methods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetadata, getWriteableName, setMetadata, subAggregation, subAggregation, subAggregations, toXContent, writeTo
Methods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
buildPipelineTree, bytesToPreallocate, doRewrite, getMinimalSupportedVersion, getName, getOutputFieldNames, getPipelineAggregations, getSubAggregations, isInSortOrderExecutionRequired, rewrite, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
NAME
- See Also:
-
REGISTRY_KEY
-
PARSER
public static final org.elasticsearch.xcontent.ObjectParser<IpPrefixAggregationBuilder,String> PARSER -
PREFIX_LENGTH_FIELD
public static final org.elasticsearch.xcontent.ParseField PREFIX_LENGTH_FIELD -
IS_IPV6_FIELD
public static final org.elasticsearch.xcontent.ParseField IS_IPV6_FIELD -
APPEND_PREFIX_LENGTH_FIELD
public static final org.elasticsearch.xcontent.ParseField APPEND_PREFIX_LENGTH_FIELD -
MIN_DOC_COUNT_FIELD
public static final org.elasticsearch.xcontent.ParseField MIN_DOC_COUNT_FIELD -
KEYED_FIELD
public static final org.elasticsearch.xcontent.ParseField 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:AggregationBuilder
Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetadata
. Used byAggregationBuilder.rewrite(QueryRewriteContext)
.- Specified by:
shallowCopy
in classAggregationBuilder
-
bucketCardinality
Description copied from class:AggregationBuilder
A rough count of the number of buckets thatAggregator
s built by this builder will contain per owning parent bucket.- Specified by:
bucketCardinality
in classAggregationBuilder
-
getType
Description copied from interface:BaseAggregationBuilder
The name of the type of aggregation built by this builder. -
innerWriteTo
Description copied from class:ValuesSourceAggregationBuilder
Write subclass's state to the stream.- Specified by:
innerWriteTo
in classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
- Throws:
IOException
-
getRegistryKey
- Specified by:
getRegistryKey
in classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
-
defaultValueSourceType
Description copied from class:ValuesSourceAggregationBuilder
Aggregations should use this method to define aValuesSourceType
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.- Specified by:
defaultValueSourceType
in 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:
innerBuild
in 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 org.elasticsearch.xcontent.XContentBuilder doXContentBody(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException - Specified by:
doXContentBody
in classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
- Throws:
IOException
-
equals
- Overrides:
equals
in classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classValuesSourceAggregationBuilder<IpPrefixAggregationBuilder>
-