use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class TDigestPercentileRanksIT method testSingleValuedFieldPartiallyUnmapped.
@Override
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery()).addAggregation(randomCompression(percentileRanks("percentile_ranks")).field("value").values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue, maxValue);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class TDigestPercentileRanksIT method testMultiValuedFieldWithValueScriptReverse.
public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
final double[] pcts = randomPercents(-maxValues, -minValues);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(randomCompression(percentileRanks("percentile_ranks")).field("values").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, -maxValues, -minValues);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class TDigestPercentileRanksIT 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 = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(randomCompression(percentileRanks("percentile_ranks")).script(script).values(pcts)).execute().actionGet();
assertHitCount(searchResponse, 10);
final PercentileRanks values = searchResponse.getAggregations().get("percentile_ranks");
assertConsistent(pcts, values, minValue - 1, maxValue - 1);
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class TDigestPercentileRanksIT method testOrderBySubAggregation.
public void testOrderBySubAggregation() {
boolean asc = randomBoolean();
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(histogram("histo").field("value").interval(2L).subAggregation(randomCompression(percentileRanks("percentile_ranks").field("value").values(99))).order(Order.aggregation("percentile_ranks", "99", asc))).execute().actionGet();
assertHitCount(searchResponse, 10);
Histogram histo = searchResponse.getAggregations().get("histo");
double previous = asc ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
for (Histogram.Bucket bucket : histo.getBuckets()) {
PercentileRanks values = bucket.getAggregations().get("percentile_ranks");
double p99 = values.percent(99);
if (asc) {
assertThat(p99, greaterThanOrEqualTo(previous));
} else {
assertThat(p99, lessThanOrEqualTo(previous));
}
previous = p99;
}
}
use of org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks in project elasticsearch by elastic.
the class TDigestPercentileRanksIT method testMultiValuedFieldWithValueScriptWithParams.
@Override
public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(randomCompression(percentileRanks("percentile_ranks")).field("values").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, minValues - 1, maxValues - 1);
}
Aggregations