How to prevent duplicate documents to be indexed in an index

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