use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class HDRPercentileRanksIT method testMultiValuedField.
@Override
public void testMultiValuedField() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits).field("values").values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValues, maxValues, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class HDRPercentileRanksIT method testScriptSingleValued.
@Override
public void testScriptSingleValued() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits).script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap())).values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue, maxValue, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class HDRPercentileRanksIT method testSingleValuedFieldWithValueScriptWithParams.
@Override
public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits).field("value").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params)).values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue - 1, maxValue - 1, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class HDRPercentileRanksIT method testSingleValuedFieldWithValueScript.
@Override
public void testSingleValuedFieldWithValueScript() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits).field("value").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())).values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue - 1, maxValue - 1, sigDigits);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class HDRPercentileRanksIT method testSingleValuedField.
@Override
public void testSingleValuedField() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits).field("value").values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue, maxValue, sigDigits);
}
Aggregations