Skip to content

Commit 52719b2

Browse files
authored
Add more missing AggregationBuilder getters (#25198)
* Add more missing AggregationBuilder getters - getMetadata for all aggs - various getters on TermsAggBuilder (without "get" prefix to maintain convention) - Also makes InternalSum's ctor public, to follow suit of other metrics (min/max/avg/etc)
1 parent ce11b89 commit 52719b2

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

core/src/main/java/org/elasticsearch/search/aggregations/AbstractAggregationBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.search.internal.SearchContext;
2525

2626
import java.io.IOException;
27+
import java.util.Collections;
2728
import java.util.Map;
2829
import java.util.Objects;
2930

@@ -115,6 +116,11 @@ public AB setMetaData(Map<String, Object> metaData) {
115116
return (AB) this;
116117
}
117118

119+
@Override
120+
public Map<String, Object> getMetaData() {
121+
return Collections.unmodifiableMap(metaData);
122+
}
123+
118124
@Override
119125
public final String getWriteableName() {
120126
// We always use the type of the aggregation as the writeable name

core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public String getName() {
6464
@Override
6565
public abstract AggregationBuilder setMetaData(Map<String, Object> metaData);
6666

67+
/** Return any associated metadata with this {@link AggregationBuilder}. */
68+
public abstract Map<String, Object> getMetaData();
69+
6770
/** Add a sub aggregation to this builder. */
6871
public abstract AggregationBuilder subAggregation(AggregationBuilder aggregation);
6972

core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ public TermsAggregationBuilder size(int size) {
148148
return this;
149149
}
150150

151+
/**
152+
* Returns the number of term buckets currently configured
153+
*/
154+
public int size() {
155+
return bucketCountThresholds.getRequiredSize();
156+
}
157+
151158
/**
152159
* Sets the shard_size - indicating the number of term buckets each shard
153160
* will return to the coordinating node (the node that coordinates the
@@ -163,6 +170,13 @@ public TermsAggregationBuilder shardSize(int shardSize) {
163170
return this;
164171
}
165172

173+
/**
174+
* Returns the number of term buckets per shard that are currently configured
175+
*/
176+
public int shardSize() {
177+
return bucketCountThresholds.getShardSize();
178+
}
179+
166180
/**
167181
* Set the minimum document count terms should have in order to appear in
168182
* the response.
@@ -176,6 +190,13 @@ public TermsAggregationBuilder minDocCount(long minDocCount) {
176190
return this;
177191
}
178192

193+
/**
194+
* Returns the minimum document count required per term
195+
*/
196+
public long minDocCount() {
197+
return bucketCountThresholds.getMinDocCount();
198+
}
199+
179200
/**
180201
* Set the minimum document count terms should have on the shard in order to
181202
* appear in the response.
@@ -189,6 +210,13 @@ public TermsAggregationBuilder shardMinDocCount(long shardMinDocCount) {
189210
return this;
190211
}
191212

213+
/**
214+
* Returns the minimum document count required per term, per shard
215+
*/
216+
public long shardMinDocCount() {
217+
return bucketCountThresholds.getShardMinDocCount();
218+
}
219+
192220
/** Set a new order on this builder and return the builder so that calls
193221
* can be chained. A tie-breaker may be added to avoid non-deterministic ordering. */
194222
public TermsAggregationBuilder order(BucketOrder order) {

core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public class InternalSum extends InternalNumericMetricsAggregation.SingleValue implements Sum {
3535
private final double sum;
3636

37-
InternalSum(String name, double sum, DocValueFormat formatter, List<PipelineAggregator> pipelineAggregators,
37+
public InternalSum(String name, double sum, DocValueFormat formatter, List<PipelineAggregator> pipelineAggregators,
3838
Map<String, Object> metaData) {
3939
super(name, pipelineAggregators, metaData);
4040
this.sum = sum;

0 commit comments

Comments
 (0)