|
@@ -128,8 +128,9 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.interval(1L)
|
|
|
.minDocCount(0)
|
|
|
.subAggregation(
|
|
|
- percentileRanks("percentile_ranks").field("value").method(PercentilesMethod.HDR)
|
|
|
- .numberOfSignificantValueDigits(sigDigits).values(10, 15)))
|
|
|
+ percentileRanks("percentile_ranks", new double[]{10, 15})
|
|
|
+ .field("value").method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits)))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
|
|
@@ -152,8 +153,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx_unmapped")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("value").values(0, 10, 15, 100))
|
|
|
+ percentileRanks("percentile_ranks", new double[]{0, 10, 15, 100})
|
|
|
+ .method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L));
|
|
@@ -175,8 +178,8 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("value").values(pcts))
|
|
|
+ percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -185,6 +188,36 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
assertConsistent(pcts, values, minValue, maxValue, sigDigits);
|
|
|
}
|
|
|
|
|
|
+ public void testNullValuesField() throws Exception {
|
|
|
+ int sigDigits = randomSignificantDigits();
|
|
|
+ final double[] pcts = null;
|
|
|
+ IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client()
|
|
|
+ .prepareSearch("idx")
|
|
|
+ .setQuery(matchAllQuery())
|
|
|
+ .addAggregation(
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
+ .method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
+ .execute().actionGet());
|
|
|
+ assertThat(e.getMessage(), equalTo("[values] must not be null: [percentile_ranks]"));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testEmptyValuesField() throws Exception {
|
|
|
+ int sigDigits = randomSignificantDigits();
|
|
|
+ final double[] pcts = new double[0];
|
|
|
+ IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client()
|
|
|
+ .prepareSearch("idx")
|
|
|
+ .setQuery(matchAllQuery())
|
|
|
+ .addAggregation(
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
+ .method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
+ .execute().actionGet());
|
|
|
+ assertThat(e.getMessage(), equalTo("[values] must not be an empty array: [percentile_ranks]"));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void testSingleValuedFieldGetProperty() throws Exception {
|
|
|
int sigDigits = randomSignificantDigits();
|
|
@@ -194,8 +227,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
global("global").subAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("value").values(pcts)))
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
+ .method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value")))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -221,8 +256,8 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("value").values(pcts))
|
|
|
+ percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -239,8 +274,8 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx", "idx_unmapped")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("value").values(pcts))
|
|
|
+ percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("value"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -257,12 +292,11 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
.field("value")
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -281,12 +315,11 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
.field("value")
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params)))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -303,8 +336,8 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
- .field("values").values(pcts))
|
|
|
+ percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits)
|
|
|
+ .field("values"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -321,12 +354,11 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
.field("values")
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -342,12 +374,11 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
.field("values")
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "20 - _value", emptyMap()))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "20 - _value", emptyMap())))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -366,12 +397,11 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
.field("values")
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params)))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -388,11 +418,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
- .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap()))
|
|
|
- .values(pcts))
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap())))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -414,11 +443,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
- .script(script)
|
|
|
- .values(pcts))
|
|
|
+ .script(script))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -438,11 +466,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
- .script(script)
|
|
|
- .values(pcts))
|
|
|
+ .script(script))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -461,11 +488,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(
|
|
|
- percentileRanks("percentile_ranks")
|
|
|
+ percentileRanks("percentile_ranks", pcts)
|
|
|
.method(PercentilesMethod.HDR)
|
|
|
.numberOfSignificantValueDigits(sigDigits)
|
|
|
- .script(script)
|
|
|
- .values(pcts))
|
|
|
+ .script(script))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -483,8 +509,8 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
.addAggregation(
|
|
|
histogram("histo").field("value").interval(2L)
|
|
|
.subAggregation(
|
|
|
- percentileRanks("percentile_ranks").field("value").method(PercentilesMethod.HDR)
|
|
|
- .numberOfSignificantValueDigits(sigDigits).values(99))
|
|
|
+ percentileRanks("percentile_ranks", new double[]{99}).field("value").method(PercentilesMethod.HDR)
|
|
|
+ .numberOfSignificantValueDigits(sigDigits))
|
|
|
.order(BucketOrder.aggregation("percentile_ranks", "99", asc))).execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -508,7 +534,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
|
|
.addAggregation(terms("terms").field("value").order(BucketOrder.compound(BucketOrder.aggregation("filter>ranks.99", true)))
|
|
|
.subAggregation(filter("filter", termQuery("value", 100))
|
|
|
- .subAggregation(percentileRanks("ranks").method(PercentilesMethod.HDR).values(99).field("value"))))
|
|
|
+ .subAggregation(percentileRanks("ranks", new double[]{99}).method(PercentilesMethod.HDR).field("value"))))
|
|
|
.get();
|
|
|
|
|
|
assertHitCount(searchResponse, 10);
|
|
@@ -553,8 +579,10 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
|
|
|
// Test that a request using a script does not get cached
|
|
|
SearchResponse r = client()
|
|
|
- .prepareSearch("cache_test_idx").setSize(0).addAggregation(percentileRanks("foo").method(PercentilesMethod.HDR).field("d")
|
|
|
- .values(50.0).script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
|
|
|
+ .prepareSearch("cache_test_idx").setSize(0)
|
|
|
+ .addAggregation(percentileRanks("foo", new double[]{50.0})
|
|
|
+ .method(PercentilesMethod.HDR).field("d")
|
|
|
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
|
|
|
.get();
|
|
|
assertSearchResponse(r);
|
|
|
|
|
@@ -566,7 +594,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
|
|
// To make sure that the cache is working test that a request not using
|
|
|
// a script is cached
|
|
|
r = client().prepareSearch("cache_test_idx").setSize(0)
|
|
|
- .addAggregation(percentileRanks("foo").method(PercentilesMethod.HDR).field("d").values(50.0)).get();
|
|
|
+ .addAggregation(percentileRanks("foo", new double[]{50.0}).method(PercentilesMethod.HDR).field("d")).get();
|
|
|
assertSearchResponse(r);
|
|
|
|
|
|
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
|