# Prevent new document with the same docuemnt id replacing the old one

**URL:** <https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104>\
**Category:** Logstash\
**Created:** [February 1, 2018, 8:43pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104 "2018-02-01T20:43:46Z")\
**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:** [February 1, 2018, 8:43pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/1 "2018-02-01T20:43:46Z")

</div>

Hi,

I am using a custom document id to avoid duplicate in Logstash. However, I notice that if the same document with the same document id gets parsed to the same index, it will replace the original one, which means @timestamp will be updated. Is there a way to prevent new document with the same document id flowing into the same index? Thank you so much.

--Tao

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 1, 2018, 8:50pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/2 "2018-02-01T20:50:02Z")

</div>

You cannot do that if the documents are in the same index, the ID is really the unique key.

---

<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, 9:11pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/3 "2018-02-01T21:11:18Z")

</div>

Hi warkolm,

Thank you so much for your reply. I just want to keep the original and ignore duplicate. Are there any ways to do that?

--Tao

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 1, 2018, 9:26pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/4 "2018-02-01T21:26:38Z")

</div>

Not within Elasticsearch, it will accept the document. I can't immediately think of another way though sorry.

---

<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, 9:42pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/5 "2018-02-01T21:42:35Z")

</div>

Thank you so much. At least I get rid of duplicate for 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:** [March 1, 2018, 9:42pm UTC](https://discuss.elastic.co/t/prevent-new-document-with-the-same-docuemnt-id-replacing-the-old-one/118104/6 "2018-03-01T21:42:40Z")

</div>

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