-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix date rounding for date math parsing (#90458) in #89693 the rounding logic was only applied when a field was present on a pattern. This is incorrect as for dates like "2020" we want to default to "2020-01-01T23:59:59.999..." when rounding is enabled. This commit always applies monthOfYear or dayofMonth defaulting (when rounding enabled) except when the dayOfYear is set closes #90187 backport(#90458) (cherry picked from commit 3f3a95e)
- Loading branch information
Showing
4 changed files
with
156 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 90458 | ||
summary: Fix date rounding for date math parsing | ||
area: Infra/Core | ||
type: bug | ||
issues: | ||
- 90187 |
121 changes: 121 additions & 0 deletions
121
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/500_date_range.yml
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,121 @@ | ||
setup: | ||
- skip: | ||
version: " - 8.5.99" | ||
reason: awaits backports | ||
- do: | ||
indices.create: | ||
index: dates_year_only | ||
body: | ||
mappings: | ||
properties: | ||
date: | ||
type: date | ||
format: uuuu | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{ "index" : { "_index" : "dates_year_only", "_id" : "first" } }' | ||
- '{"date" : "1900", "field" : 1 }' | ||
- '{ "index" : { "_index" : "dates_year_only", "_id" : "second" } }' | ||
- '{"date" : "2022", "field" : 1 }' | ||
- '{ "index" : { "_index" : "dates_year_only", "_id" : "third" } }' | ||
- '{"date" : "2022", "field" : 2 }' | ||
- '{ "index" : { "_index" : "dates_year_only", "_id" : "fourth" } }' | ||
- '{"date" : "1500", "field" : 2 }' | ||
|
||
- do: | ||
indices.create: | ||
index: dates | ||
body: | ||
mappings: | ||
properties: | ||
date: | ||
type: date | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{ "index" : { "_index" : "dates", "_id" : "first" } }' | ||
- '{"date" : "1900-01-01T12:12:12.123456789Z", "field" : 1 }' | ||
- '{ "index" : { "_index" : "dates", "_id" : "second" } }' | ||
- '{"date" : "2022-01-01T12:12:12.123456789Z", "field" : 1 }' | ||
- '{ "index" : { "_index" : "dates", "_id" : "third" } }' | ||
- '{"date" : "2022-01-03T12:12:12.123456789Z", "field" : 2 }' | ||
- '{ "index" : { "_index" : "dates", "_id" : "fourth" } }' | ||
- '{"date" : "1500-01-01T12:12:12.123456789Z", "field" : 2 }' | ||
- '{ "index" : { "_index" : "dates", "_id" : "fifth" } }' | ||
- '{"date" : "1500-01-05T12:12:12.123456789Z", "field" : 2 }' | ||
|
||
--- | ||
"test range query for all docs with year uuuu": | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: dates | ||
body: | ||
query: | ||
range: | ||
date: | ||
gte: 1000 | ||
lte: 2023 | ||
format: uuuu | ||
|
||
- match: { hits.total: 5 } | ||
- length: { hits.hits: 5 } | ||
|
||
--- | ||
"test match query gte and lt for single result with year uuuu": | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: dates | ||
body: | ||
query: | ||
range: | ||
date: | ||
gte: 1500 #1500-01-01T00:00:00 | ||
lte: 1500 #1500-01-01T23:59:59 | ||
format: uuuu | ||
|
||
- match: { hits.total: 1 } | ||
- length: { hits.hits: 1 } | ||
- match: { hits.hits.0._id: "fourth" } | ||
|
||
--- | ||
"test match query gte and lte with year uuuu": | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: dates | ||
body: | ||
query: | ||
range: | ||
date: | ||
gte: 1500 | ||
lte: 2000 | ||
format: uuuu | ||
|
||
- match: { hits.total: 3 } | ||
- length: { hits.hits: 3 } | ||
- match: { hits.hits.0._id: "first" } | ||
- match: { hits.hits.1._id: "fourth" } | ||
- match: { hits.hits.2._id: "fifth" } | ||
|
||
--- | ||
"test match query with year uuuu": | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: dates_year_only | ||
body: | ||
query: | ||
match: | ||
date: | ||
query: "1500" | ||
|
||
- match: { hits.total: 1 } | ||
- length: { hits.hits: 1 } | ||
- match: { hits.hits.0._id: "fourth" } |
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