use of org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles in project elasticsearch by elastic.
the class HDRPercentilesIT method testMultiValuedFieldWithValueScriptReverse.
public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).field("values").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "20 - _value", emptyMap())).percentiles(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
assertConsistent(pcts, percentiles, 20 - maxValues, 20 - minValues, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles in project elasticsearch by elastic.
the class HDRPercentilesIT method testSingleValuedFieldGetProperty.
@Override
public void testSingleValuedFieldGetProperty() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(global("global").subAggregation(percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).field("value").percentiles(pcts))).execute().actionGet();
assertHitCount(searchResponse, 10);
Global global = searchResponse.getAggregations().get("global");
assertThat(global, notNullValue());
assertThat(global.getName(), equalTo("global"));
assertThat(global.getDocCount(), equalTo(10L));
assertThat(global.getAggregations(), notNullValue());
assertThat(global.getAggregations().asMap().size(), equalTo(1));
Percentiles percentiles = global.getAggregations().get("percentiles");
assertThat(percentiles, notNullValue());
assertThat(percentiles.getName(), equalTo("percentiles"));
assertThat(global.getProperty("percentiles"), sameInstance(percentiles));
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles in project elasticsearch by elastic.
the class HDRPercentilesIT method testScriptSingleValuedWithParams.
@Override
public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).script(script).percentiles(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles in project elasticsearch by elastic.
the class HDRPercentilesIT method testSingleValuedField.
@Override
public void testSingleValuedField() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomIntBetween(1, 5);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).field("value").percentiles(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
assertConsistent(pcts, percentiles, minValue, maxValue, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles in project elasticsearch by elastic.
the class HDRPercentilesIT method testScriptMultiValuedWithParams.
@Override
public void testScriptMultiValuedWithParams() throws Exception {
Script script = AggregationTestScriptsPlugin.DECREMENT_ALL_VALUES;
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).script(script).percentiles(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1, sigDigits);
}
Aggregations