# Is it possible to make document\_id unique among indices?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690
**Category:** Elasticsearch
**Created:** [January 30, 2018, 7:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690 "2018-01-30T19:14:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Tao\_Liu1](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@Tao\_Liu1](https://discuss.elastic.co/u/Tao_Liu1)
#### Post date: [January 30, 2018, 7:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/1 "2018-01-30T19:14:16Z")

</div>

Hi,

I recently used a custom document\_id to avoid duplicate in ES. However, I found that the same document can be indexed in different indices. Is there a way to make sure the document itself is unique in ES? Thank you very much.

---

<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: [January 31, 2018, 8:40am UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/2 "2018-01-31T08:40:01Z")

</div>

Hey,

no, this needs to be done on the client side. Adding the index name to the id might be sufficient already there.

--Alex

---

<div class="post-metadata">

### Author: ![Tao\_Liu1](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@Tao\_Liu1](https://discuss.elastic.co/u/Tao_Liu1)
#### Post date: [January 31, 2018, 2:51pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/3 "2018-01-31T14:51:51Z")

</div>

Hi Alex,

Thanks for your reply. Actually I have a custom id as a combination of several fields from the log. My problem is, in the same index, the id will avoid duplicate. However, if the same message gets indexed in different indices, then two identical logs will exist. Is there a way to make sure that, with the unique id, there will only be one record in ES, among indices? Thank you so much.

--Tao

---

<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: [January 31, 2018, 8:39pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/4 "2018-01-31T20:39:12Z")

</div>

Hey,

no, there is no guarantee for that within ES.

--Alex

---

<div class="post-metadata">

### Author: ![Tao\_Liu1](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@Tao\_Liu1](https://discuss.elastic.co/u/Tao_Liu1)
#### Post date: [February 1, 2018, 3:17pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/5 "2018-02-01T15:17:26Z")

</div>

Hi Alex,

Thanks for your reply. Does it mean that with the default routing value (as document id), ES can only ensure the document id is unique in the same index?

--Tao

---

<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: [March 1, 2018, 3:17pm UTC](https://discuss.elastic.co/t/is-it-possible-to-make-document-id-unique-among-indices/117690/6 "2018-03-01T15:17:37Z")

</div>

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