# How to delete duplicate data base on query on 2.3

**URL:** <https://discuss.elastic.co/t/how-to-delete-duplicate-data-base-on-query-on-2-3/81962>\
**Category:** Elasticsearch\
**Created:** [April 11, 2017, 11:05am UTC](https://discuss.elastic.co/t/how-to-delete-duplicate-data-base-on-query-on-2-3/81962 "2017-04-11T11:05:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weibin.wu](https://avatars.discourse-cdn.com/v4/letter/w/4491bb/32.png) [@weibin.wu](https://discuss.elastic.co/u/weibin.wu)\
**Post date:** [April 11, 2017, 11:05am UTC](https://discuss.elastic.co/t/how-to-delete-duplicate-data-base-on-query-on-2-3/81962/1 "2017-04-11T11:05:58Z")

</div>

Hi Elasticsearch:

Seems delete base on query in 2.3 was removed.  
We uploaded the same data multiple time so that's why we need to delete the duplicate data by query.

And because we are using AWS ES , so there is no way to install delete-by-query plugin.

Is there a way to fix the data in elasticsearch 2.3?

---

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [April 12, 2017, 1:46am UTC](https://discuss.elastic.co/t/how-to-delete-duplicate-data-base-on-query-on-2-3/81962/2 "2017-04-12T01:46:04Z")

</div>

Well start with the basic

[https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/delete-by-query-plugin-reason.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/delete-by-query-plugin-reason.html)

Ok now that is done,

2 options, write a query that fetches all the doc id's and then write some code to issue the request to delete each object. curl -XDELETE 'localhost:9200/customer/external/2?pretty'

[https://www.elastic.co/guide/en/elasticsearch/reference/2.3/\_deleting\_documents.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/_deleting_documents.html)

Or, a slightly easier way

Use logstash to re-index

```auto
Logstash (Input elasticsearch old index) -> Filter ( If bad doc, drop) -> Output (Elasticsearch new index))

```

---

<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:** [May 10, 2017, 1:50am UTC](https://discuss.elastic.co/t/how-to-delete-duplicate-data-base-on-query-on-2-3/81962/3 "2017-05-10T01:50:00Z")

</div>

Closed on May 10, 2017, 1:50am UTC

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