Fix ordering

Core changed how you specify bucket ordering so we need to change
too.

Original commit: elastic/x-pack-elasticsearch@73d09f64c7
This commit is contained in:
Nik Everett 2017-05-11 13:44:17 -04:00
parent 16aa600830
commit 3ad2da0d87
2 changed files with 6 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import org.elasticsearch.common.text.Text;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.search.aggregations.AggregationBuilders; 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.DateHistogramInterval;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHit;
@ -45,7 +46,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
SearchResponse response = client().prepareSearch("my-index") SearchResponse response = client().prepareSearch("my-index")
.addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") .addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp")
.dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) .dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false)))
.get(); .get();
CompareCondition condition = new CompareCondition("ctx.payload.aggregations.rate.buckets.0.doc_count", CompareCondition.Op.GTE, 5, 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") response = client().prepareSearch("my-index")
.addAggregation(AggregationBuilders.dateHistogram("rate") .addAggregation(AggregationBuilders.dateHistogram("rate")
.field("@timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) .field("@timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false)))
.get(); .get();
ctx = mockExecutionContext("_name", new Payload.XContent(response)); ctx = mockExecutionContext("_name", new Payload.XContent(response));

View File

@ -17,6 +17,7 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.search.aggregations.AggregationBuilders; 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.DateHistogramInterval;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.internal.InternalSearchResponse; import org.elasticsearch.search.internal.InternalSearchResponse;
@ -75,7 +76,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
SearchResponse response = client().prepareSearch("my-index") SearchResponse response = client().prepareSearch("my-index")
.addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") .addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp")
.dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC)) .dateHistogramInterval(DateHistogramInterval.HOUR).order(BucketOrder.count(false)))
.get(); .get();
ScriptService scriptService = internalCluster().getInstance(ScriptService.class); ScriptService scriptService = internalCluster().getInstance(ScriptService.class);
@ -90,7 +91,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
refresh(); refresh();
response = client().prepareSearch("my-index").addAggregation(AggregationBuilders.dateHistogram("rate").field("@timestamp") 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(); .get();
ctx = mockExecutionContext("_name", new Payload.XContent(response)); ctx = mockExecutionContext("_name", new Payload.XContent(response));