test: filtered query -> bool query
Original commit: elastic/x-pack-elasticsearch@18ba61b9e9
This commit is contained in:
parent
0ef1bfb9a2
commit
ed3821b65b
|
@ -206,8 +206,8 @@ public class SearchTransformTests extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchRequest request = Requests.searchRequest("idx").source(searchSource().query(boolQuery()
|
SearchRequest request = Requests.searchRequest("idx").source(searchSource().query(boolQuery()
|
||||||
.must(rangeQuery("date").gt("{{ctx.trigger.scheduled_time}}"))
|
.must(constantScoreQuery(rangeQuery("date").gt("{{ctx.trigger.scheduled_time}}")))
|
||||||
.must(rangeQuery("date").lt("{{ctx.execution_time}}"))
|
.must(constantScoreQuery(rangeQuery("date").lt("{{ctx.execution_time}}")))
|
||||||
.must(termQuery("value", "{{ctx.payload.value}}"))));
|
.must(termQuery("value", "{{ctx.payload.value}}"))));
|
||||||
|
|
||||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||||
|
@ -222,9 +222,12 @@ public class SearchTransformTests extends ESIntegTestCase {
|
||||||
assertThat(result, notNullValue());
|
assertThat(result, notNullValue());
|
||||||
assertThat(result.type(), is(SearchTransform.TYPE));
|
assertThat(result.type(), is(SearchTransform.TYPE));
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx").setQuery(
|
SearchResponse response = client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(
|
||||||
termQuery("value", "val_3"))
|
boolQuery()
|
||||||
.get();
|
.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);
|
Payload expectedPayload = new Payload.XContent(response);
|
||||||
|
|
||||||
// we need to remove the "took" field from teh response as this is the only field
|
// we need to remove the "took" field from teh response as this is the only field
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"filtered": {
|
"bool": {
|
||||||
"query": {
|
"must" : [
|
||||||
"match": {
|
{
|
||||||
"event_type": {
|
"match": {
|
||||||
"query": "a",
|
"event_type": {
|
||||||
"type": "boolean"
|
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,24 +1,26 @@
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"filtered": {
|
"bool": {
|
||||||
"query": {
|
"must" : [
|
||||||
"match": {
|
{
|
||||||
"event_type": {
|
"match": {
|
||||||
"query": "a",
|
"event_type": {
|
||||||
"type": "boolean"
|
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue