Skip to content

Floating-point value accepted for a date field during indexing, but fails later on update/re-index #71311

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

Open
capnbab opened this issue Apr 5, 2021 · 7 comments
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@capnbab
Copy link

capnbab commented Apr 5, 2021

Elasticsearch version (bin/elasticsearch --version):
7.9.2

Plugins installed: []

JVM version (java -version):
openjdk version "15" 2020-09-15
OpenJDK Runtime Environment AdoptOpenJDK (build 15+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)

OS version (uname -a if on a Unix-like system):
Linux 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
Floating-point values are accepted into a date field during initial document insert, but cause later update/re-index operations to fail.

I would expect that since the value is not a properly formatted date string, a long, or an integer, that the insert should have thrown the bad format error.

Steps to reproduce:

# 1. delete the index
curl -XDELETE localhost:9200/test

# 2. create index, include a date property
curl -X PUT "localhost:9200/test?pretty" -H 'Content-Type: application/json' -d'{
  "mappings": {
    "properties": {
      "some_date": { "type": "date" }
    }
  }
}'

# 3. insert a document, using a float for the date. this should error for bad date format, but actually succeeds.
curl -X PUT "localhost:9200/test/_doc/1?pretty" -H 'Content-Type: application/json' -d'{
  "some_date" : 1616619193352.3
}'

# 4. try to update the document (e.g. add a new field). returns date_time_parse_exception.
curl -X POST "localhost:9200/test/_update/1?pretty" -H 'Content-Type: application/json' -d'{
  "doc": {
    "name": "new_name"
  }
}'
@capnbab capnbab added >bug needs:triage Requires assignment of a team area label labels Apr 5, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Apr 6, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@DJRickyB DJRickyB removed the needs:triage Requires assignment of a team area label label Apr 6, 2021
@joegallo joegallo added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Apr 6, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Apr 6, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@joegallo joegallo added Team:Search Meta label for search team and removed :Core/Features/Features Team:Data Management Meta label for data/management team Team:Search Meta label for search team labels Apr 6, 2021
@cbuescher
Copy link
Member

So far I can see that on update the "_source" we need to re-parse contains the original date value in scientific notation ({"some_date":1.6166191933523E12,"name":"new_name"}), which is probably an effect of either the initial json parsing of the original document or an effect of rendering it when we retrieve it again for the update. I don't know if it is possible to avoid this conversion or if as an alternative we could make the date parser accept scientific notation, since it already seems to be able to coerce the numeric part from the original input. Maybe @pgomulka has some ideas around this?

@pgomulka
Copy link
Contributor

pgomulka commented Apr 12, 2021

The date is correct it means 1616619193352 millis and 3 nanoseconds
The exception on update looks like a bug.
Related to #70040 - a fix by @nik9000 - but that PR did not fix this for the update scenario.
a workaround is to wrap the date in quotes. "some_date" : "1616619193352.3"
I will try to work on a fix


a similar problem still ongoing #70085
also related to #69382

this can also likely be fixed by - #46531

@pgomulka pgomulka self-assigned this Apr 12, 2021
@nik9000
Copy link
Member

nik9000 commented Apr 12, 2021

I was sort of hoping that we could avoid ever doing anything on the "map of maps" side. But a bug like this sort of forces us to do something there. I'm not sure what, frankly.

@javanna javanna added the priority:normal A label for assessing bug priority to be used by ES engineers label Jun 13, 2024
@javanna javanna added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 16, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@hitesh-55
Copy link

Do we have any update on this or any work around ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

10 participants