diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AbstractAggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/AbstractAggregationBuilder.java index ef82c48b4e7a2..bbd9e3a20f7cd 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AbstractAggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AbstractAggregationBuilder.java @@ -24,6 +24,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; +import java.util.Collections; import java.util.Map; import java.util.Objects; @@ -115,6 +116,11 @@ public AB setMetaData(Map metaData) { return (AB) this; } + @Override + public Map getMetaData() { + return Collections.unmodifiableMap(metaData); + } + @Override public final String getWriteableName() { // We always use the type of the aggregation as the writeable name diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java index 16f8ef2444fec..694a78f9d1c7f 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java @@ -64,6 +64,9 @@ public String getName() { @Override public abstract AggregationBuilder setMetaData(Map metaData); + /** Return any associated metadata with this {@link AggregationBuilder}. */ + public abstract Map getMetaData(); + /** Add a sub aggregation to this builder. */ public abstract AggregationBuilder subAggregation(AggregationBuilder aggregation); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java index cb239781e3e40..d534b572f96d6 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java @@ -148,6 +148,13 @@ public TermsAggregationBuilder size(int size) { return this; } + /** + * Returns the number of term buckets currently configured + */ + public int size() { + return bucketCountThresholds.getRequiredSize(); + } + /** * Sets the shard_size - indicating the number of term buckets each shard * will return to the coordinating node (the node that coordinates the @@ -163,6 +170,13 @@ public TermsAggregationBuilder shardSize(int shardSize) { return this; } + /** + * Returns the number of term buckets per shard that are currently configured + */ + public int shardSize() { + return bucketCountThresholds.getShardSize(); + } + /** * Set the minimum document count terms should have in order to appear in * the response. @@ -176,6 +190,13 @@ public TermsAggregationBuilder minDocCount(long minDocCount) { return this; } + /** + * Returns the minimum document count required per term + */ + public long minDocCount() { + return bucketCountThresholds.getMinDocCount(); + } + /** * Set the minimum document count terms should have on the shard in order to * appear in the response. @@ -189,6 +210,13 @@ public TermsAggregationBuilder shardMinDocCount(long shardMinDocCount) { return this; } + /** + * Returns the minimum document count required per term, per shard + */ + public long shardMinDocCount() { + return bucketCountThresholds.getShardMinDocCount(); + } + /** Set a new order on this builder and return the builder so that calls * can be chained. A tie-breaker may be added to avoid non-deterministic ordering. */ public TermsAggregationBuilder order(BucketOrder order) { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java index 576f1ea52cf6b..6f723f4fbcb28 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java @@ -34,7 +34,7 @@ public class InternalSum extends InternalNumericMetricsAggregation.SingleValue implements Sum { private final double sum; - InternalSum(String name, double sum, DocValueFormat formatter, List pipelineAggregators, + public InternalSum(String name, double sum, DocValueFormat formatter, List pipelineAggregators, Map metaData) { super(name, pipelineAggregators, metaData); this.sum = sum;