-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Use date format in date_range
mapping before fallback to default
#29310
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
1 similar comment
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Pinging @elastic/es-search-aggs |
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.
Hi @liketic, yet another great PR, thanks for picking this up. I think the fix in RangeFieldMapper is good, however I'd like the test to be less generic and randomized. In its current form it seems to test all kinds of ranges (not only date), many versions etc. while I would be convinced more that the fix works if it would stick closer to the scenario described in #29282. I'd remove a lot of the randomization and make this test more specialized about the scenario described there I think.
Thanks @cbuescher ! I updated the PR. Please review again. 👍 |
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.
Hi @liketic, thanks for reworking the test. I'm not sure I'm convinced about what the test does yet, I think currently it might not do the right thing (at the moment is passes with or without your change in the RangeFieldMapper).
I hope the comment I left makes sense, happy to clear things up if you have questions.
assertEquals( | ||
RangeType.DATE.rangeQuery(FIELDNAME, true, from, to, true, | ||
true, relation, null, defaultParser, context), | ||
fieldType.rangeQuery(from, to, true, true, relation, null, null, context)); |
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.
I'm not sure what is tested here, can you explain?
As far as I can see, fieldType.rangeQuery
only redirects to DATE#rangeQuery
, so other than checking if the parser gets picked up, this test is not doing much in my opinion, but I might miss something.
I'd prefer it it would check that the from/to values are parsed correctly using the parser supplied by fieldType.setDateTimeFormatter
. For that I think the from/to values should be String representations of dates that DEFAULT_DATE_TIME_FORMATTER would reject otherwise. I'd like to see a test that checks that using the DEFAULT_DATE_TIME_FORMATTER we get an error (expectThrows) and with the right parser the query contains the expected min/max values. Accessing the min/max values of the Lucene query might be a bit tricky on first inspection of the code, but I think most shape relations should produce LongRange queries which Query can be cast to to use the getters.
@liketic checking in to see if we can get this PR in soon. The fix is fine I think, only the test needs some reworking as I mentioned in the comments. Let me know what you think and if you have time to get back to this in the next week or so. |
@cbuescher My apologies for the delay. Thanks for your comments. I'll fix it before next week. |
@liketic no problem at all, I didn't want to set a date either. Just checking if you need anything, please take your time. |
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.
@liketic thanks a lot, this looks good to me. I will kick of a run of CI testing. There seems to be a new requirement to add changelog information to PRs that I'm not completely up to date with myself but I will come back with some info on what we need here (if anything).
@elasticmachine test this please |
date_range
mapping before fallback to default
@liketic we seem to require additions to a changlelog file now for bugfixes and features. Could you add a line mentioning this PRs title and number similar to e.g. https://github.com/elastic/elasticsearch/pull/29641/files#diff-297418c07078d2b31d8e94a7d34b5255 to the |
@liketic when you add the changelog, could you also merge in master once more, CI run didn't pass but its not related to this change I think. |
@liketic I found out how to push to user PRs and added the changlog entry and merged in master, hope you don't mind. |
@elasticmachine test this please |
@elasticmachine test this please |
@liketic finally a green CI run. I merged this to master and will also port it to the 6.4 branch. |
…or-you * elastic/master: (22 commits) Docs: Test examples that recreate lang analyzers (elastic#29535) BulkProcessor to retry based on status code (elastic#29329) Add GET Repository High Level REST API (elastic#30362) add a comment explaining the need for RetryOnReplicaException on missing mappings Add `coordinating_only` node selector (elastic#30313) Stop forking groovyc (elastic#30471) Avoid setting connection request timeout (elastic#30384) Use date format in `date_range` mapping before fallback to default (elastic#29310) Watcher: Increase HttpClient parallel sent requests (elastic#30130) Mute ML upgrade test (elastic#30458) Stop forking javac (elastic#30462) Client: Deprecate many argument performRequest (elastic#30315) Docs: Use task_id in examples of tasks (elastic#30436) Security: Rename IndexLifecycleManager to SecurityIndexManager (elastic#30442) [Docs] Fix typo in cardinality-aggregation.asciidoc (elastic#30434) Avoid NPE in `more_like_this` when field has zero tokens (elastic#30365) Build: Switch to building javadoc with html5 (elastic#30440) Add a quick tour of the project to CONTRIBUTING (elastic#30187) Reindex: Use request flavored methods (elastic#30317) Silence SplitIndexIT.testSplitIndexPrimaryTerm test failure. (elastic#30432) ...
* master: Upgrade to Lucene-7.4-snapshot-6705632810 (#30519) add version compatibility from 6.4.0 after backport, see #30319 (#30390) Security: Simplify security index listeners (#30466) Add proper longitude validation in geo_polygon_query (#30497) Remove Discovery.AckListener.onTimeout() (#30514) Build: move generated-resources to build (#30366) Reindex: Fold "with all deps" project into reindex (#30154) Isolate REST client single host tests (#30504) Solve Gradle deprecation warnings around shadowJar (#30483) SAML: Process only signed data (#30420) Remove BWC repository test (#30500) Build: Remove xpack specific run task (#30487) AwaitsFix IntegTestZipClientYamlTestSuiteIT#indices.split tests LLClient: Add setJsonEntity (#30447) Expose CommonStatsFlags directly in IndicesStatsRequest. (#30163) Silence IndexUpgradeIT test failures. (#30430) Bump Gradle heap to 1792m (#30484) [docs] add warning for read-write indices in force merge documentation (#28869) Avoid deadlocks in cache (#30461) Test: remove hardcoded list of unconfigured ciphers (#30367) mute SplitIndexIT due to #30416 Docs: Test examples that recreate lang analyzers (#29535) BulkProcessor to retry based on status code (#29329) Add GET Repository High Level REST API (#30362) add a comment explaining the need for RetryOnReplicaException on missing mappings Add `coordinating_only` node selector (#30313) Stop forking groovyc (#30471) Avoid setting connection request timeout (#30384) Use date format in `date_range` mapping before fallback to default (#29310) Watcher: Increase HttpClient parallel sent requests (#30130) # Conflicts: # x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java
* 6.x: Upgrade to Lucene-7.4-snapshot-6705632810 (#30519) Remove Discovery.AckListener.onTimeout() (#30514) Build: move generated-resources to build (#30366) Reindex: Fold "with all deps" project into reindex (#30154) Isolate REST client single host tests (#30504) Remove BWC repository test (#30500) Build: Remove xpack specific run task (#30487) AwaitsFix IntegTestZipClientYamlTestSuiteIT#indices.split tests LLClient: Add setJsonEntity (#30447) [docs] add warning for read-write indices in force merge documentation (#28869) Avoid deadlocks in cache (#30461) BulkProcessor to retry based on status code (#29329) Avoid setting connection request timeout (#30384) Test: remove hardcoded list of unconfigured ciphers (#30367) Add GET Repository High Level REST API (#30362) mute SplitIndexIT due to #30416 Docs: Test examples that recreate lang analyzers (#29535) add a comment explaining the need for RetryOnReplicaException on missing mappings Pass the task to broadcast actions (#29672) Stop forking groovyc (#30471) Add `coordinating_only` node selector (#30313) Fix accidental error in changelog Use date format in `date_range` mapping before fallback to default (#29310) Watcher: Increase HttpClient parallel sent requests (#30130) [Security][Tests] Azeri(Turkish) locale tripps opensaml dependency
Thanks @cbuescher ! |
If the date format is not forced in query, use the format in mapping before fallback to the default format.
Closes #29282