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

Add new default date format #5163

Merged
merged 5 commits into from
Oct 25, 2023
Merged

Add new default date format #5163

merged 5 commits into from
Oct 25, 2023

Conversation

kolchfa-aws
Copy link
Collaborator

Fixes #5158

Checklist

  • By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and subject to the Developers Certificate of Origin.
    For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Fanit Kolchina <[email protected]>
@kolchfa-aws kolchfa-aws added release-notes PR: Include this PR in the automated release notes v2.11.0 labels Oct 5, 2023
@kolchfa-aws kolchfa-aws requested a review from hdhalter as a code owner October 5, 2023 14:55
@kolchfa-aws kolchfa-aws self-assigned this Oct 5, 2023
@kolchfa-aws
Copy link
Collaborator Author

@CaptainDredge Could you review this PR for technical accuracy?

A date math expression contains a fixed date, optionally followed by one or more mathematical expressions. The fixed date may be either `now` (current date and time in milliseconds since the epoch) or a string ending with `||` that specifies a date (for example, `2022-05-18||`). The date must be in the `strict_date_time_no_millis||strict_date_optional_time||epoch_millis` format.

If you specify multiple date formats in the field mapping, OpenSearch uses the first format to convert the milliseconds since the epoch value to a string. <br>
If a field mapping for a field contains no format, OpenSearch uses `strict_date_optional_time` to convert the epoch value to a string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If a field mapping for a field contains no format, OpenSearch uses `strict_date_optional_time` to convert the epoch value to a string.
If a field mapping for a field contains no format, OpenSearch uses `strict_date_optional_time` format to convert the epoch value to a string.

@CaptainDredge
Copy link
Contributor

@reta should we add here that user can revert to older format by disabling feature flag, would like to know your opinion

@reta
Copy link
Contributor

reta commented Oct 6, 2023

@reta should we add here that user can revert to older format by disabling feature flag, would like to know your opinion

@CaptainDredge Yes please, we have a new feature flag that should be documented, thank you. The 2.11 was cut, unless we get the green light to backport it to 2.11, this would be 2.12 feature.

@kolchfa-aws
Copy link
Collaborator Author

@CaptainDredge I have reworded to incorporate your suggestion. Please let me know:

  • what's the feature flag, how the user can enable the feature flag, and what's the behavior when it's enabled/disabled
  • if this is still going into 2.11
    Thanks

@reta
Copy link
Contributor

reta commented Oct 6, 2023

what's the feature flag, how the user can enable the feature flag, and what's the behavior when it's enabled/disabled

Just an example of feature flags in the system (and how we document them)

@CaptainDredge
Copy link
Contributor

CaptainDredge commented Oct 6, 2023

what's the feature flag

opensearch.experimental.optimization.datetime_formatter_caching.enabled

how the user can enable the feature flag

Note that the above feature flag is enabled by default, user has to disable it if he/she wants to go to the previous default formatter

Disabling the feature flag

There are several methods for disabling the feature flag, depending on the installation type.

Disable on a node using a tarball installation

The flag is toggled using a new jvm parameter that is set either in OPENSEARCH_JAVA_OPTS or in config/jvm.options:

  • Option 1: Update config/jvm.options by adding the following line:

    -Dopensearch.experimental.optimization.datetime_formatter_caching.enabled=false
  • Option 2: Use the OPENSEARCH_JAVA_OPTS environment variable:

    export OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.optimization.datetime_formatter_caching.enabled=false"

Disable with Docker containers

If you're running Docker, add the following line to docker-compose.yml underneath the opensearch-node and environment sections:

OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.optimization.datetime_formatter_caching.enabled=false"

what's the behavior when it's enabled/disabled

Its enabled by default and therefore opensearch will use the new default format introduced along with an optimisation which cache last successfully parsed formatter to parse the datetime field for the next document getting indexed in the same shard. When the featureflag is disabled opensearch will use the old format along with disabling the above optimisation

what's the behavior when it's enabled/disabled

I couldn't get the green light for the backport PRs to go in 2.11. I think it'll now go in 2.12 😞

@CaptainDredge
Copy link
Contributor

@reta shouldn't we ideally have a common section for instructions on enabling and disabling feature flag instead of mentioning the process in every feature. This will allow us to just then document the new feature flag briefly with a relative link to the featureflag enable/disable documentation

@reta
Copy link
Contributor

reta commented Oct 6, 2023

@reta shouldn't we ideally have a common section for instructions on enabling and disabling feature flag instead of mentioning the process in every feature

Totally, we could ask documentation team to help us with restructuring the docs to have common details on feature flags and than we could only mention the flag name(s) in the feature specific docs, @kolchfa-aws how does it sound? thank you!

@kolchfa-aws
Copy link
Collaborator Author

@reta Are all feature flags enabled in the same way? If so, we definitely need to put it in one place.

@CaptainDredge
Copy link
Contributor

@kolchfa-aws Yes all the feature flags are enabled in the same way

@reta
Copy link
Contributor

reta commented Oct 6, 2023

@kolchfa-aws Yes all the feature flags are enabled in the same way

All the same way, correct.

@kolchfa-aws kolchfa-aws added v2.12.0 and removed release-notes PR: Include this PR in the automated release notes v2.11.0 labels Oct 6, 2023
@kolchfa-aws kolchfa-aws modified the milestone: v2.12 Oct 6, 2023
@hdhalter hdhalter added this to the v2.12 milestone Oct 6, 2023
@CaptainDredge
Copy link
Contributor

@kolchfa-aws this change has been backported to 2.x and will be released in v2.12. What's the way ahead to get this documentation merged now?
opensearch-project/OpenSearch#10448

Copy link
Collaborator

@natebower natebower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kolchfa-aws LGTM!

@kolchfa-aws kolchfa-aws added the release-notes PR: Include this PR in the automated release notes label Oct 20, 2023
@kolchfa-aws
Copy link
Collaborator Author

@CaptainDredge @reta I added a "how to enable experimental features" section. Could you review this commit to make sure everything looks good? 03edad8. Then we can merge.

Copy link
Contributor

@CaptainDredge CaptainDredge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Collaborator

@natebower natebower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kolchfa-aws Just one comment. Thanks!

@@ -223,7 +227,7 @@ GET testindex/_search

The date field type supports using date math to specify durations in queries. For example, the `gt`, `gte`, `lt`, and `lte` parameters in [range queries]({{site.url}}{{site.baseurl}}/query-dsl/term/range/) and the `from` and `to` parameters in [date range aggregations]({{site.url}}{{site.baseurl}}/query-dsl/aggregations/bucket/date-range/) accept date math expressions.

A date math expression contains a fixed date, optionally followed by one or more mathematical expressions. The fixed date may be either `now` (current date and time in milliseconds since the epoch) or a string ending with `||` that specifies a date (for example, `2022-05-18||`). The date must be in the `strict_date_time_no_millis||strict_date_optional_time||epoch_millis` format.
A date math expression contains a fixed date, optionally followed by one or more mathematical expressions. The fixed date may be either `now` (current date and time in milliseconds since the epoch) or a string ending with `||` that specifies a date (for example, `2022-05-18||`). The date must be in the [default format](#default-format), which by default is `strict_date_time_no_millis||strict_date_optional_time||epoch_millis`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last sentence might be a bit redundant (the default format by default is).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there are two options for the default format and one of them is the default one :)

Signed-off-by: Fanit Kolchina <[email protected]>
@kolchfa-aws kolchfa-aws merged commit 49889b4 into main Oct 25, 2023
3 checks passed
harshavamsi pushed a commit to harshavamsi/documentation-website that referenced this pull request Oct 31, 2023
* Add new default date format

Signed-off-by: Fanit Kolchina <[email protected]>

* Update _field-types/supported-field-types/date.md

Signed-off-by: kolchfa-aws <[email protected]>

* Add enabling experimental features section

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
vagimeli pushed a commit that referenced this pull request Dec 21, 2023
* Add new default date format

Signed-off-by: Fanit Kolchina <[email protected]>

* Update _field-types/supported-field-types/date.md

Signed-off-by: kolchfa-aws <[email protected]>

* Add enabling experimental features section

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
@Naarcha-AWS Naarcha-AWS deleted the date-update branch March 28, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes PR: Include this PR in the automated release notes v2.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DOC] Update Date field type Documentation
5 participants