Could not index event to Elasticsearch

I am trying to index my data into Elasticsearch from logstash but I keep getting this type of errors for all indices.
Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"mongo_test", :routing=>nil, :_type=>"_doc"}, #LogStash::Event:0x38f82cb], :response=>{"index"=>{"_index"=>"mongo_test", "_type"=>"_doc", "_id"=>"htaHMHkBhVyJ3tOuXKpe", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters."}}}}

Can you please help me in debugging the problem that is causing this to happen?
Thanks and Regards


You need to extract the _id field from the original document and assign it as the elasticsearch _id.

I moved your question to #elastic-stack:logstash