From 3ad2da0d87a2b79d9b580970cd7a8c172a42d341 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 11 May 2017 13:44:17 -0400 Subject: [PATCH] Fix ordering Core changed how you specify bucket ordering so we need to change too. Original commit: elastic/x-pack-elasticsearch@73d09f64c758615500cfa3e19e498230e6e0a9be --- .../xpack/watcher/condition/CompareConditionSearchTests.java | 5 +++-- .../xpack/watcher/condition/ScriptConditionSearchTests.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java index 3973e3b053e..e1a2f4a8225 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.text.Text; import org.elasticsearch.index.Index; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.BucketOrder; import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.SearchHit; @@ -45,7 +46,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC SearchResponse response = client().prepareSearch("my-index") .addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") - .dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) + .dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false))) .get(); CompareCondition condition = new CompareCondition("ctx.payload.aggregations.rate.buckets.0.doc_count", CompareCondition.Op.GTE, 5, @@ -63,7 +64,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC response = client().prepareSearch("my-index") .addAggregation(AggregationBuilders.dateHistogram("rate") - .field("@timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) + .field("@timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false))) .get(); ctx = mockExecutionContext("_name", new Payload.XContent(response)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionSearchTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionSearchTests.java index ea5fec9dabd..b07bc79b222 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionSearchTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionSearchTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.BucketOrder; import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.internal.InternalSearchResponse; @@ -75,7 +76,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa SearchResponse response = client().prepareSearch("my-index") .addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") - .dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) + .dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false))) .get(); ScriptService scriptService = internalCluster().getInstance(ScriptService.class); @@ -90,7 +91,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa refresh(); response = client().prepareSearch("my-index").addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") - .dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) + .dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false))) .get(); ctx = mockExecutionContext("_name", new Payload.XContent(response));