diff --git a/watcher/src/test/java/org/elasticsearch/watcher/transform/search/SearchTransformTests.java b/watcher/src/test/java/org/elasticsearch/watcher/transform/search/SearchTransformTests.java index e0b971ee4ac..678ea288bab 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/transform/search/SearchTransformTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/transform/search/SearchTransformTests.java @@ -206,8 +206,8 @@ public class SearchTransformTests extends ESIntegTestCase { refresh(); SearchRequest request = Requests.searchRequest("idx").source(searchSource().query(boolQuery() - .must(rangeQuery("date").gt("{{ctx.trigger.scheduled_time}}")) - .must(rangeQuery("date").lt("{{ctx.execution_time}}")) + .must(constantScoreQuery(rangeQuery("date").gt("{{ctx.trigger.scheduled_time}}"))) + .must(constantScoreQuery(rangeQuery("date").lt("{{ctx.execution_time}}"))) .must(termQuery("value", "{{ctx.payload.value}}")))); SearchTransform searchTransform = TransformBuilders.searchTransform(request).build(); @@ -222,9 +222,12 @@ public class SearchTransformTests extends ESIntegTestCase { assertThat(result, notNullValue()); assertThat(result.type(), is(SearchTransform.TYPE)); - SearchResponse response = client().prepareSearch("idx").setQuery( - termQuery("value", "val_3")) - .get(); + SearchResponse response = client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setQuery( + boolQuery() + .must(constantScoreQuery(rangeQuery("date").gt(parseDate("2015-01-01T00:00:00", UTC)))) + .must(constantScoreQuery(rangeQuery("date").lt(parseDate("2015-01-04T00:00:00", UTC)))) + .must(termQuery("value", "val_3")) + ).get(); Payload expectedPayload = new Payload.XContent(response); // we need to remove the "took" field from teh response as this is the only field diff --git a/watcher/src/test/resources/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache b/watcher/src/test/resources/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache index 822b9146255..cdc73453c0a 100644 --- a/watcher/src/test/resources/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache +++ b/watcher/src/test/resources/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache @@ -1,24 +1,26 @@ { "query": { - "filtered": { - "query": { - "match": { - "event_type": { - "query": "a", - "type": "boolean" + "bool": { + "must" : [ + { + "match": { + "event_type": { + "query": "a", + "type": "boolean" + } + } + }, + { + "range": { + "_timestamp": { + "from": "{{ctx.trigger.scheduled_time}}||-{{seconds_param}}", + "to": "{{ctx.trigger.scheduled_time}}", + "include_lower": true, + "include_upper": true + } } } - }, - "filter": { - "range": { - "_timestamp": { - "from": "{{ctx.trigger.scheduled_time}}||-{{seconds_param}}", - "to": "{{ctx.trigger.scheduled_time}}", - "include_lower": true, - "include_upper": true - } - } - } + ] } } } \ No newline at end of file diff --git a/watcher/src/test/resources/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache b/watcher/src/test/resources/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache index 822b9146255..cdc73453c0a 100644 --- a/watcher/src/test/resources/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache +++ b/watcher/src/test/resources/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache @@ -1,24 +1,26 @@ { "query": { - "filtered": { - "query": { - "match": { - "event_type": { - "query": "a", - "type": "boolean" + "bool": { + "must" : [ + { + "match": { + "event_type": { + "query": "a", + "type": "boolean" + } + } + }, + { + "range": { + "_timestamp": { + "from": "{{ctx.trigger.scheduled_time}}||-{{seconds_param}}", + "to": "{{ctx.trigger.scheduled_time}}", + "include_lower": true, + "include_upper": true + } } } - }, - "filter": { - "range": { - "_timestamp": { - "from": "{{ctx.trigger.scheduled_time}}||-{{seconds_param}}", - "to": "{{ctx.trigger.scheduled_time}}", - "include_lower": true, - "include_upper": true - } - } - } + ] } } } \ No newline at end of file