# Multiple documents with same \_id

**URL:** https://discuss.elastic.co/t/multiple-documents-with-same-id/108567
**Category:** Elasticsearch
**Created:** [November 21, 2017, 1:32pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567 "2017-11-21T13:32:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)
#### Post date: [November 21, 2017, 1:32pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/1 "2017-11-21T13:32:32Z")

</div>

Hi,  
I am using single master, 2 data nodes for my cluster. (6shards, 1Replica)  
I also have routing specified while indexing documents.

When i have indexed about 20Gb of documents, i can see multiple documents with same \_ID 🙄

Can this happen ? As i assume that ID are unique, and even if we create many document with same ID but different content it should overwrite it and increment the \_version.

Please help !!

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [November 21, 2017, 1:34pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/2 "2017-11-21T13:34:35Z")

</div>

This is either a bug in Elasticsearch or you indexed two documents with the same `_id` but different routing values.

---

<div class="post-metadata">

### Author: ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)
#### Post date: [November 21, 2017, 1:37pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/3 "2017-11-21T13:37:44Z")

</div>

The later case is true.  
I have indexed two documents with same \_id but different value.

But, i thought ES keeps the \_id unique per index. So even if the routing value is different the index is the same.

Can you please put some light on above assumption ?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [November 21, 2017, 1:42pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/4 "2017-11-21T13:42:51Z")

</div>

From [the docs:](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-routing-field.html#_unique_ids_with_custom_routing)

> When indexing documents specifying a custom \_routing, the uniqueness of the \_id is not guaranteed across all of the shards in the index. In fact, documents with the same \_id might end up on different shards if indexed with different \_routing values.  
> It is up to the user to ensure that IDs are unique across the index.

---

<div class="post-metadata">

### Author: ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)
#### Post date: [November 21, 2017, 1:45pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/5 "2017-11-21T13:45:08Z")

</div>

Thanks mark. I would rethink of the strategy now 🙃

---

<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: [December 19, 2017, 1:45pm UTC](https://discuss.elastic.co/t/multiple-documents-with-same-id/108567/6 "2017-12-19T13:45:16Z")

</div>

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