2

Index Mapping

"review_start_datetime" : {
   "type" : "date"
},
"review_start_time" : {
   "type" : "date"
}

Class

from elasticsearch_dsl import Document, Date

class DocumentX(Document):
    review_start_datetime = Date(format='yyyy-MM-dd HH:mm:ss',
                            default_timezone="UTC")

Creating Data

doc = DocumentX.get('DEMO_54ddab6')
doc.review_start_time = datetime.datetime.now()
doc.review_start_datetime = datetime.datetime.now()
doc.save()

While executing save method it gives below error only for review_start_datetime field not for review_start_time.

elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', "failed to parse field [review_start_datetime] of type [date] in document with id 'DEMO_54ddab6'")

2 Answers2

3

By Adding DateTime format in index mapping it will resolve.

"review_start_datetime" : {
    "type" : "date",
    "format" : "yyyy-MM-dd HH:mm:ss"
},
0

I encountered the same error in various tools, e.g., Apache NiFi, and Logstash. The problem in my case is that I want to put MongoDB documents in the Elasticsearch index, where these documents already include the _id field, and when I want to make that Elasticsearch database, the new field _id will be made that can not exist with the earlier one. So, this results in the error. The solution may be to remove/change _id field in the documents before putting them into Elastic.

Ahmad Tanha
  • 121
  • 1
  • 8
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30069096) – My Stack Overfloweth Oct 13 '21 at 16:38