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)
This commit is contained in:
parent
ce11b894b4
commit
52719b2118
|
@ -24,6 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
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 abstract class AbstractAggregationBuilder<AB extends AbstractAggregationB
|
|||
return (AB) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMetaData() {
|
||||
return Collections.unmodifiableMap(metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getWriteableName() {
|
||||
// We always use the type of the aggregation as the writeable name
|
||||
|
|
|
@ -64,6 +64,9 @@ public abstract class AggregationBuilder
|
|||
@Override
|
||||
public abstract AggregationBuilder setMetaData(Map<String, Object> metaData);
|
||||
|
||||
/** Return any associated metadata with this {@link AggregationBuilder}. */
|
||||
public abstract Map<String, Object> getMetaData();
|
||||
|
||||
/** Add a sub aggregation to this builder. */
|
||||
public abstract AggregationBuilder subAggregation(AggregationBuilder aggregation);
|
||||
|
||||
|
|
|
@ -148,6 +148,13 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
|
|||
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 class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
|
|||
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 class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
|
|||
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 class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
|
|||
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) {
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Objects;
|
|||
public class InternalSum extends InternalNumericMetricsAggregation.SingleValue implements Sum {
|
||||
private final double sum;
|
||||
|
||||
InternalSum(String name, double sum, DocValueFormat formatter, List<PipelineAggregator> pipelineAggregators,
|
||||
public InternalSum(String name, double sum, DocValueFormat formatter, List<PipelineAggregator> pipelineAggregators,
|
||||
Map<String, Object> metaData) {
|
||||
super(name, pipelineAggregators, metaData);
|
||||
this.sum = sum;
|
||||
|
|
Loading…
Reference in New Issue