forked from elastic/elasticsearch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query DSL: Cache range filter on date field by default
A range filter on a date field with a numeric `from`/`to` value is **not** cached by default: DELETE /test PUT /test/t/1 { "date": "2014-01-01" } GET /_validate/query?explain { "query": { "filtered": { "filter": { "range": { "date": { "from": 0 } } } } } } Returns: "explanation": "ConstantScore(no_cache(date:[0 TO *]))" This patch fixes as well not caching `from`/`to` when using `now` value not rounded. Previously, a query like: GET /_validate/query?explain { "query": { "filtered": { "filter": { "range": { "date": { "from": "now" "to": "now/d+1" } } } } } } was cached. Also, this patch does not cache anymore `now` even if the user asked for caching it. As it won't be cached at all by definition. Added as well tests for all possible combinations. Closes elastic#7114. (cherry picked from commit 9e68687)
- Loading branch information
Showing
7 changed files
with
254 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ | |
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/org/elasticsearch/index/query/date_range_in_boolean_with_long_value.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"constant_score": { | ||
"filter": { | ||
"bool": { | ||
"must": [ | ||
{ | ||
"term": { | ||
"foo": { | ||
"value": "bar" | ||
} | ||
} | ||
}, | ||
{ | ||
"range" : { | ||
"born" : { | ||
"gte": 1325376000, | ||
"lte": 1577836800 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../java/org/elasticsearch/index/query/date_range_in_boolean_with_long_value_not_cached.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"constant_score": { | ||
"filter": { | ||
"bool": { | ||
"must": [ | ||
{ | ||
"term": { | ||
"foo": { | ||
"value": "bar" | ||
} | ||
} | ||
}, | ||
{ | ||
"range" : { | ||
"_cache" : false, | ||
"born" : { | ||
"gte": 1325376000, | ||
"lte": 1577836800 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters