# Delete API for duplicate records

**URL:** <https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438>\
**Category:** Kibana\
**Created:** [August 25, 2021, 5:16am UTC](https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438 "2021-08-25T05:16:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)\
**Post date:** [August 25, 2021, 5:16am UTC](https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438/1 "2021-08-25T05:16:11Z")

</div>

I have documents with duplicate data say like  
Doc 1 :- { id : 1, empid : 1, name : Peter }  
Doc 2 :- { id : 2, empid : 2, name : Leo}  
Doc 3 :- { id : 1, empid : 1, name : Peter }  
Doc 4 :- { id : 3, empid : 3, name : Denver }

I want to remove the documents having duplicate data .i.e, Doc 3 in above case. Is there any query to delete the documents like this.

Thanks in advance..

---

<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:** [August 25, 2021, 5:19am UTC](https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438/2 "2021-08-25T05:19:20Z")

</div>

Not natively no, because you want to compare and then delete, which would be 2 queries that you would to chain external to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)\
**Post date:** [August 26, 2021, 5:02am UTC](https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438/3 "2021-08-26T05:02:12Z")

</div>

What would be the two queries if decided to do so ?

---

<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:** [September 23, 2021, 5:02am UTC](https://discuss.elastic.co/t/delete-api-for-duplicate-records/282438/4 "2021-09-23T05:02:43Z")

</div>

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