Skip to content
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

Merged
merged 8 commits into from
May 9, 2018

Conversation

liketic
Copy link
Contributor

@liketic liketic commented Mar 30, 2018

If the date format is not forced in query, use the format in mapping before fallback to the default format.

Closes #29282

@elasticmachine
Copy link
Collaborator

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
@elasticmachine
Copy link
Collaborator

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?

@cbuescher cbuescher self-assigned this Apr 3, 2018
@cbuescher cbuescher self-requested a review April 3, 2018 15:29
@cbuescher cbuescher added the :Search/Search Search-related issues that do not fall into other categories label Apr 3, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

Copy link
Member

@cbuescher cbuescher left a 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.

@liketic
Copy link
Contributor Author

liketic commented Apr 6, 2018

Thanks @cbuescher ! I updated the PR. Please review again. 👍

Copy link
Member

@cbuescher cbuescher left a 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));
Copy link
Member

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.

@cbuescher
Copy link
Member

@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.

@liketic
Copy link
Contributor Author

liketic commented May 3, 2018

@cbuescher My apologies for the delay. Thanks for your comments. I'll fix it before next week.

@cbuescher
Copy link
Member

@liketic no problem at all, I didn't want to set a date either. Just checking if you need anything, please take your time.

@cbuescher cbuescher added the >bug label May 7, 2018
Copy link
Member

@cbuescher cbuescher left a 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).

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher cbuescher changed the title Use date format in mapping before fallback to default Use date format in date_range mapping before fallback to default May 7, 2018
@cbuescher
Copy link
Member

@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 docs/CHANGELOG.asciidoc. I think this fix should also be backported to the next 6.x branches. At the moment I believe this means putting the same entry in two places (under 7.0 and 6.4). Thanks a lot.

@cbuescher
Copy link
Member

@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.

@cbuescher
Copy link
Member

@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

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher cbuescher merged commit 0c6789b into elastic:master May 9, 2018
@cbuescher
Copy link
Member

@liketic finally a green CI run. I merged this to master and will also port it to the 6.4 branch.

cbuescher pushed a commit that referenced this pull request May 9, 2018
…29310)

If the date format is not forced in query, use the format in mapping before 
fallback to the default format.

Closes #29282
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 9, 2018
…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)
  ...
dnhatn added a commit that referenced this pull request May 10, 2018
* 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
dnhatn added a commit that referenced this pull request May 10, 2018
* 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
@liketic liketic deleted the fix-issues/29282 branch May 12, 2018 08:03
@liketic
Copy link
Contributor Author

liketic commented May 12, 2018

Thanks @cbuescher !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v6.4.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants