# Setting unique \_id

**URL:** <https://discuss.elastic.co/t/setting-unique-id/125968>\
**Category:** Elasticsearch\
**Created:** [March 28, 2018, 4:08pm UTC](https://discuss.elastic.co/t/setting-unique-id/125968 "2018-03-28T16:08:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ventrca](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@ventrca](https://discuss.elastic.co/u/ventrca)\
**Post date:** [March 28, 2018, 4:08pm UTC](https://discuss.elastic.co/t/setting-unique-id/125968/1 "2018-03-28T16:08:25Z")

</div>

Hi, in my application I have to prevent the insertion of duplicates, so what I did until now is to set as \_id a digest of my message.  
But I realized that two documents in different index can have same \_id.

My index pattern:  
logstash-YYYY.DD.MM

So if the same message arrives in two different days I will have two log entries with the same \_id.

Is there a way to have a unique index per pattern or the only solution is to have just one index?

---

<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:** [April 25, 2018, 4:09pm UTC](https://discuss.elastic.co/t/setting-unique-id/125968/2 "2018-04-25T16:09:26Z")

</div>

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