# Could not index event to Elasticsearch

**URL:** <https://discuss.elastic.co/t/could-not-index-event-to-elasticsearch/271929>\
**Category:** Logstash\
**Created:** [May 3, 2021, 6:02am UTC](https://discuss.elastic.co/t/could-not-index-event-to-elasticsearch/271929 "2021-05-03T06:02:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BASHEER\_DS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basheer_ds/32/88104_2.png) [@BASHEER\_DS](https://discuss.elastic.co/u/BASHEER_DS)\
**Post date:** [May 3, 2021, 6:02am UTC](https://discuss.elastic.co/t/could-not-index-event-to-elasticsearch/271929/1 "2021-05-03T06:02:03Z")

</div>

Hi,  
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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 3, 2021, 7:15am UTC](https://discuss.elastic.co/t/could-not-index-event-to-elasticsearch/271929/2 "2021-05-03T07:15:44Z")

</div>

Welcome!

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 31, 2021, 7:16am UTC](https://discuss.elastic.co/t/could-not-index-event-to-elasticsearch/271929/3 "2021-05-31T07:16:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
