I am trying to use persistence API, using elasticsearch-dsl version 6.2.1 as follow:
class MyClass(Document):
start = Date(format='dd-MM-yyyy HH:mm:ss:SSS')
stop = Date(format='dd-MM-yyyy HH:mm:ss:SSS')
When I call MyClass.init()
I see (through Kibana) that indeed the mapping is as I expected:
"start": {
"type": "date",
"format": "dd-MM-yyyy HH:mm:ss:SSS"
},
"stop": {
"type": "date",
"format": "dd-MM-yyyy HH:mm:ss:SSS"
}
I have variable my_instance
which is an instance of MyClass
.
my_instance.start
and my_instance.stop
hold strings like
'15-06-2018 02:54:05:382'
When I call my_instance.save()
I get the following exception:
elasticsearch_dsl.exceptions.ValidationException: {'start':
[ValidationException("Could not parse date from the value ('15-06-2018
02:54:05:281')", ValueError('Unknown string format:', '15-06-2018
02:54:05:281'))], 'stop': [ValidationException("Could not parse date from the
value ('15-06-2018 02:54:05:382')", ValueError('Unknown string format:', '15-
06-2018 02:54:05:382'))]}
What am I doing wrong?
Unfortunately elasticsearch-dsl
currently only supports dates in ISO format. If you want to use any other format you need to specify the (de) serialization yourself.