# How to prevent duplicate documents to be indexed in an index

**URL:** <https://discuss.elastic.co/t/how-to-prevent-duplicate-documents-to-be-indexed-in-an-index/12750>\
**Category:** Elasticsearch\
**Created:** [July 10, 2013, 8:25pm UTC](https://discuss.elastic.co/t/how-to-prevent-duplicate-documents-to-be-indexed-in-an-index/12750 "2013-07-10T20:25:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![npathan](https://avatars.discourse-cdn.com/v4/letter/n/ac8455/32.png) [@npathan](https://discuss.elastic.co/u/npathan)\
**Post date:** [July 10, 2013, 8:25pm UTC](https://discuss.elastic.co/t/how-to-prevent-duplicate-documents-to-be-indexed-in-an-index/12750/1 "2013-07-10T20:25:01Z")

</div>

Hello,

I am indexing some product details in the elasticsearch. I want that items with same itemId should not be indexed. I tried to use setOpType("create") while preparing the mapping. It does not work. Is it the right way or not?

Thanks,  
Naz

---

<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:** [July 6, 2017, 2:27am UTC](https://discuss.elastic.co/t/how-to-prevent-duplicate-documents-to-be-indexed-in-an-index/12750/2 "2017-07-06T02:27:04Z")

</div>


