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

secondOfDay Date Field API not working v7.2.0 #44411

Closed
markwheal opened this issue Jul 16, 2019 · 3 comments
Closed

secondOfDay Date Field API not working v7.2.0 #44411

markwheal opened this issue Jul 16, 2019 · 3 comments
Assignees
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache

Comments

@markwheal
Copy link

Elasticsearch version (bin/elasticsearch --version):
v7.2.0

Plugins installed: []
JVM version (java -version):
OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:

Since upgrading to 7.2.0 my scripted field of doc['timestamp'].date.secondOfDay has stopped working, and no data shows up in Discover mode!

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.

doc['field_name'].date.secondOfDay is given as an example in documentation - https://www.elastic.co/guide/en/elasticsearch/reference/7.2/modules-scripting-expression.html

I have also tried doc['@timestamp'].date.secondOfDay - note the different field name; timestamp is our own field that we populate.

@albertzaharovits albertzaharovits added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Jul 16, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@albertzaharovits
Copy link
Contributor

@pgomulka pgomulka self-assigned this Jul 18, 2019
rjernst added a commit to rjernst/elasticsearch that referenced this issue Jul 24, 2019
While joda no longer exists in the apis for 7.x, the compatibility layer
still exists with helper methods mimicking the behavior of joda for
ZonedDateTime objects returned for date fields in scripts. This layer
was originally intended to be removed in 7.0, but is now likely to exist
for the lifetime of 7.x.

This commit adds missing methods from ChronoZonedDateTime to the compat
class. These methods were not part of joda, but are needed to act like a
real ZonedDateTime.

relates elastic#44411
@rjernst
Copy link
Member

rjernst commented Jul 24, 2019

@markwheal Your script example was:

doc['timestamp'].date.secondOfDay

This uses the .date accessor on long fields, but this was removed in #30690 for 7.0. Date fields are now accessed through .value, and the type is now ZonedDateTime. Additionally for 7.0, we have switched to java time as our backend, which means the .secondOfDay access is deprecated (this was something specifically in joda). You will need to make sure your timestamp field is a date field, and not just a long field. Long term, you should use doc['timestamp'].value.get(ChronoField.SECOND_OF_DAY). However, investigating this issue made me realize the get method is missing from our compatibility layer, so I opened #44829.

Given the issue here is use of .date, which was removed, I'm going to close this issue.

@rjernst rjernst closed this as completed Jul 24, 2019
lcawl pushed a commit to lcawl/elasticsearch that referenced this issue Jul 25, 2019
While joda no longer exists in the apis for 7.x, the compatibility layer
still exists with helper methods mimicking the behavior of joda for
ZonedDateTime objects returned for date fields in scripts. This layer
was originally intended to be removed in 7.0, but is now likely to exist
for the lifetime of 7.x.

This commit adds missing methods from ChronoZonedDateTime to the compat
class. These methods were not part of joda, but are needed to act like a
real ZonedDateTime.

relates elastic#44411
rjernst added a commit that referenced this issue Jul 25, 2019
While joda no longer exists in the apis for 7.x, the compatibility layer
still exists with helper methods mimicking the behavior of joda for
ZonedDateTime objects returned for date fields in scripts. This layer
was originally intended to be removed in 7.0, but is now likely to exist
for the lifetime of 7.x.

This commit adds missing methods from ChronoZonedDateTime to the compat
class. These methods were not part of joda, but are needed to act like a
real ZonedDateTime.

relates #44411
jkakavas pushed a commit that referenced this issue Jul 31, 2019
While joda no longer exists in the apis for 7.x, the compatibility layer
still exists with helper methods mimicking the behavior of joda for
ZonedDateTime objects returned for date fields in scripts. This layer
was originally intended to be removed in 7.0, but is now likely to exist
for the lifetime of 7.x.

This commit adds missing methods from ChronoZonedDateTime to the compat
class. These methods were not part of joda, but are needed to act like a
real ZonedDateTime.

relates #44411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache
Projects
None yet
Development

No branches or pull requests

5 participants