-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Ingestion errors when a datetime object has 0 on the milliseconds #2941
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
Comments
Hi 👋, I'm more than happy to help on this. |
Hi! How did you make the assessment that the problem is the missing milli or nanosecond fraction? I think the problem is your timezone offset instead. First of all my understanding is that a timezone of I was able to insert datetimes with integer seconds, and also with milli or nanosecond fractions just fine, as long as I did not include the timezone offset. I was also able to insert datetimes that include valid timezone offsets, but for this I had to use a custom format for the date field. Here is a mapping that I used for my test:
Here are some examples of datetimes that worked with the above definitions. Note that I changed your
|
Sorry for the late reply, I just got back to this
And these worked as expected
With this one failing a a different validation
The rest were properly indexed Similar with
Looks like the issue is the internal Java validation from |
The more specific error message is reported under the |
We have a date field on ES8 with the following mapping
But we are getting a validation format
Due to the lack of the decimal places of the seconds.
We are sending a datetime object so it's triggering this line
elasticsearch-py/elasticsearch/serializer.py
Line 68 in 72efd52
.isoformat()
howeverisoformat
for datetime has a behavior that if there are not microseconds it will use the second level precision https://github.com/python/cpython/blob/95d9dea1c4ed1b1de80074b74301cee0b38d5541/Lib/_pydatetime.py#L177-L179I can work around this by subclassing the
JsonSerializer
and adding an overwrite for datetimes, however is there a more permanent solution you could implement in the python client?The text was updated successfully, but these errors were encountered: