# How to use "op\_type" with logstash to prevent duplicate entries?

**URL:** <https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101>\
**Category:** Logstash\
**Created:** [March 1, 2016, 10:21am UTC](https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101 "2016-03-01T10:21:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gunay](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gunay](https://discuss.elastic.co/u/gunay)\
**Post date:** [March 1, 2016, 10:21am UTC](https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101/1 "2016-03-01T10:21:07Z")

</div>

Hi,

I would like to prevent the same data log indexed twice.

I found out from the documentation that it can be achieved using "op\_type" parameter.

$ curl -XPUT '[http://localhost:9200/twitter/tweet/1?op\_type=create](http://localhost:9200/twitter/tweet/1?op_type=create)' -d '{  
"user" : "kimchy",  
"post\_date" : "2009-11-15T14:12:12",  
"message" : "trying out Elasticsearch"  
}'

However, how do you use "op\_type" in Logstash?

I am using filebeats to send data to logstash.  
In logstash, my data is parsed into JSON and sent to elastic search via the elasticsearch output plugin:

output {  
elasticsearch { hosts =\> ["localhost:9200"] }  
stdout { codec =\> rubydebug }  
}

Can I include op\_type=create in the output plugin? How, what is the syntax?

Thanks,  
Gunay

---

<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:** [March 1, 2016, 9:34pm UTC](https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101/2 "2016-03-01T21:34:40Z")

</div>

I think [https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-action](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-action) is what you are after.

---

<div class="post-metadata">

**Author:** ![gunay](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gunay](https://discuss.elastic.co/u/gunay)\
**Post date:** [March 3, 2016, 8:49am UTC](https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101/3 "2016-03-03T08:49:02Z")

</div>

Thank you very very much Mark. Indeed, it is it the action setting what I was looking for.

---

<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, 5:08am UTC](https://discuss.elastic.co/t/how-to-use-op-type-with-logstash-to-prevent-duplicate-entries/43101/4 "2017-07-06T05:08:40Z")

</div>


