-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix range query on date fields for number inputs #63692
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
Conversation
Currently, if you write a date range query with numeric 'to' or 'from' bounds, they can be interpreted as years if no format is provided. We use "strict_date_optional_time||epoch_millis" in this case that can interpret inputs like 1000 as the year 1000 for example. We should change this to always interpret and parse numbers in this case with the second option "epoch_millis" if no other formatter was provided. Closes elastic#63680
Pinging @elastic/es-search (:Search/Search) |
This is a potential fix, as @nik9000 mentioned on the issue we should discuss if we want this kind of change and, if so, should it be considered a breaking change in 8.0 or a bugfix. I tend to see this as a bug fix since the current behaviour is really trappy and very likely not expected by the user. |
server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
Outdated
Show resolved
Hide resolved
@nik9000 thanks for the review, I added another iteration but personally prefered the earlier variant. let me know what you think. Maybe I missed some simpler option? |
rest-api-spec/src/main/resources/rest-api-spec/test/field_caps/30_filter.yml
Show resolved
Hide resolved
This happens when you submit a doc too! |
@nik9000 just going through open PRs atm, do you think this needs changes or additions? Or just another round of discussion maybe? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Should we add something to the breaking changes list?
@nik9000 thanks for the review, I added a blip to the docs and an entry in the breaking changes list. Can you take another short quick look to see if what I added there makes sense to you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think 8.0.0-alpha1.asciidoc could also use a line for this.
There is a known issue in 7.x where a date parameter of a range query can be interpreted as the number of years if no format is provided. This commit always uses epoch_millis format to avoid this issue in CanMatchPreFilterSearchPhaseTests. Relates elastic#63692 Closes elastic#77122
Currently, if you write a date range query with numeric 'to' or 'from' bounds,
they can be interpreted as years if no format is provided. We use
"strict_date_optional_time||epoch_millis" in this case that can interpret inputs
like 1000 as the year 1000 for example. We should change this to always
interpret and parse numbers in this case with the second option "epoch_millis"
if no other formatter was provided.
Closes #63680