# Elastic search duplicate document with same Id and different routing

**URL:** <https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242>\
**Category:** Elasticsearch\
**Created:** [May 18, 2021, 7:26am UTC](https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242 "2021-05-18T07:26:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohanapriya\_Gopal1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanapriya_gopal1/32/78185_2.png) [@Mohanapriya\_Gopal1](https://discuss.elastic.co/u/Mohanapriya_Gopal1)\
**Post date:** [May 18, 2021, 7:26am UTC](https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242/1 "2021-05-18T07:26:43Z")

</div>

While indexing using logstash from db to elastic, we got duplicate documents with same Id and different routing.how canwe fix this

---

<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 18, 2021, 7:44am UTC](https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242/2 "2021-05-18T07:44:28Z")

</div>

Welcome!

You will probably need to reindex and provide the right `_id` and the right `_routing` key.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 18, 2021, 10:39am UTC](https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242/3 "2021-05-18T10:39:55Z")

</div>

After either deleting single documents or fully reindexing your data you can ensure, that routing is required when a document is indexed in the future.

See [\_routing field | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/mapping-routing-field.html#_making_a_routing_value_required)

---

<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:** [June 15, 2021, 10:40am UTC](https://discuss.elastic.co/t/elastic-search-duplicate-document-with-same-id-and-different-routing/273242/4 "2021-06-15T10:40:33Z")

</div>

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