# Delete duplicate items

**URL:** <https://discuss.elastic.co/t/delete-duplicate-items/19995>\
**Category:** Elasticsearch\
**Created:** [September 29, 2014, 1:07am UTC](https://discuss.elastic.co/t/delete-duplicate-items/19995 "2014-09-29T01:07:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jingzhao\_Ou](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jingzhao\_Ou](https://discuss.elastic.co/u/Jingzhao_Ou)\
**Post date:** [September 29, 2014, 1:07am UTC](https://discuss.elastic.co/t/delete-duplicate-items/19995/1 "2014-09-29T01:07:46Z")

</div>

Hi, all,

I use Elastic Search to store some JSON data like the following:

{  
"\_index" : "normalized",  
"\_type" : "90A2DAFB0621",  
"\_id" : "Fri Sep 12 16:59:50 UTC 2014",  
"\_score" : 1.0,  
"\_source":{"id":"2014-09-12T16:59:50.000Z","r":72.16,"o":74.3,"m":78.01,"s":66.99,"c":0.03,"p":2.77,"e":7.694444444444444E-6,"ec":1.8466666666666666E-6,"mo":0,"ot":64.31,"ecop":91}  
}

I changed how "\_id" is calculated in my program later on. Then, in the old data sets, there are two duplicated items for older data. I was able to find the duplicated items using the aggregation API:

{  
"aggs": {  
"types": {  
"terms": {  
"field": "\_type"  
},  
"aggs": {  
"dups": {  
"histogram": {  
"field": "id",  
"interval": 1,  
"min\_doc\_count": 2  
}  
}  
}  
}  
}  
}

I can remove the old data one by one using the delete API. But I wonder if there are any better solutions.

Thanks a lot for your help!

Jingzhao

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2d84de9f-5317-45ff-b599-2cae7f505b3a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2d84de9f-5317-45ff-b599-2cae7f505b3a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:59am UTC](https://discuss.elastic.co/t/delete-duplicate-items/19995/2 "2017-07-06T00:59:25Z")

</div>


