New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query DSL: Cache range filter on date field by default #7114
Comments
Indeed, in if (lowerTerm != null) {
if (lowerTerm instanceof Number) {
lowerVal = ((Number) lowerTerm).longValue();
} else {
String value = convertToString(lowerTerm);
cache = explicitCaching || !hasNowExpressionWithNoRounding(value);
lowerVal = parseToMilliseconds(value, context, false);
}
}
if (upperTerm != null) {
if (upperTerm instanceof Number) {
upperVal = ((Number) upperTerm).longValue();
} else {
String value = convertToString(upperTerm);
cache = explicitCaching || !hasNowExpressionWithNoRounding(value);
upperVal = parseToMilliseconds(value, context, includeUpper);
}
} |
While looking at this issue, I found that if you use a
gives:
@clintongormley Do you agree that this should be fixed as well? |
@dadoonet yes i do |
Here are the results of my findings so far (test agains master branch so before applying PR #7122): I created a range filter like this: {
"constant_score" : {
"filter" : {
"range" : {
"born" : {
"gte": <GTE>,
"lte": <LTE>
},
"_cache" : <CACHE IF NOT NULL>
}
}
}
} FailuresThe most critical ones performance wise are:
Those are minor issues performance wise.
Extreme use case: I don't know if we should cache or not this one. It produces a range filter:
Passing testsFor information, here are the successful tests:
|
This should be rewritten as a match_all filter instead. |
After talking with @martijnvg and @clintongormley, I changed the test scenario. Here are new list of failing tests:
About:
#7204 is opened for that. |
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.
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 #7114. (cherry picked from commit 9e68687)
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 #7114. (cherry picked from commit 9e68687)
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 #7114. (cherry picked from commit 9e68687)
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 #7114.
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)
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)
A range filter on a date field with a numeric
from
/to
value is not cached by default:Returns:
The text was updated successfully, but these errors were encountered: