Skip to content

Commit 869a69e

Browse files
jpountzuboness
authored andcommitted
Add the ability to set percentiles and the execution hint to PercentileBuilder.
1 parent 8424ea2 commit 869a69e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,42 @@
11
package org.elasticsearch.search.aggregations.metrics.percentile;
22

3+
import org.elasticsearch.common.xcontent.XContentBuilder;
34
import org.elasticsearch.search.aggregations.metrics.ValuesSourceMetricsAggregationBuilder;
45

6+
import java.io.IOException;
7+
58
/**
69
*
710
*/
811
public class PercentileBuilder extends ValuesSourceMetricsAggregationBuilder<PercentileBuilder> {
912

13+
private double[] percentiles;
14+
private String executionHint;
15+
1016
public PercentileBuilder(String name) {
1117
super(name, InternalPercentile.TYPE.name());
1218
}
19+
20+
public PercentileBuilder executionHint(String executionHint) {
21+
this.executionHint = executionHint;
22+
return this;
23+
}
24+
25+
public PercentileBuilder percentiles(double... percentiles) {
26+
this.percentiles = percentiles;
27+
return this;
28+
}
29+
30+
@Override
31+
protected void internalXContent(XContentBuilder builder, Params params) throws IOException {
32+
super.internalXContent(builder, params);
33+
34+
if (percentiles != null) {
35+
builder.field("percentiles", percentiles);
36+
}
37+
38+
if (executionHint != null) {
39+
builder.field("execution_hint", executionHint);
40+
}
41+
}
1342
}

0 commit comments

Comments
 (0)