# Delete efficiently

**URL:** https://discuss.elastic.co/t/delete-efficiently/18783
**Category:** Elasticsearch
**Created:** [July 22, 2014, 8:40am UTC](https://discuss.elastic.co/t/delete-efficiently/18783 "2014-07-22T08:40:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ophir\_Michaeli](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@Ophir\_Michaeli](https://discuss.elastic.co/u/Ophir_Michaeli)
#### Post date: [July 22, 2014, 8:40am UTC](https://discuss.elastic.co/t/delete-efficiently/18783/1 "2014-07-22T08:40:14Z")

</div>

Hi all,

I want to delete 1 million documents at a time from a given list of  
documents I get. The delete is by query (on one of the documents fields).  
I want to understand what is the best practice to do that.  
Loop through the million and delete one by one async, or will it cause an  
overload on elsdaticsearch, and I should delete X at a time async and wait  
till it's  
done and then delete additional X. Or is there a batch delete that does  
this work more efficiently?

Thanks

--  
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/4ef1b8d7-9682-4315-af47-ba1d21f535e2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4ef1b8d7-9682-4315-af47-ba1d21f535e2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 22, 2014, 8:53am UTC](https://discuss.elastic.co/t/delete-efficiently/18783/2 "2014-07-22T08:53:56Z")

</div>

If at the end, it will remain a small subset, you could also think of reindexing only those docs in à new index and then remove the old index.

Answering to your question, you should run your query using scan and scroll and start remove docs using a bulk.

My 2 cents

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 22 juil. 2014 à 10:40, Ophir Michaeli [ophirmichaeli@gmail.com](mailto:ophirmichaeli@gmail.com) a écrit :
> 
> Hi all,
> 
> I want to delete 1 million documents at a time from a given list of documents I get. The delete is by query (on one of the documents fields).  
> I want to understand what is the best practice to do that.  
> Loop through the million and delete one by one async, or will it cause an overload on elsdaticsearch, and I should delete X at a time async and wait till it's  
> done and then delete additional X. Or is there a batch delete that does this work more efficiently?
> 
> Thanks
> 
> --  
> 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/4ef1b8d7-9682-4315-af47-ba1d21f535e2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4ef1b8d7-9682-4315-af47-ba1d21f535e2%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/D89039EB-5B33-448B-B061-3081CF0B26C9%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/D89039EB-5B33-448B-B061-3081CF0B26C9%40pilato.fr).  
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, 1:14am UTC](https://discuss.elastic.co/t/delete-efficiently/18783/3 "2017-07-06T01:14:18Z")

</div>


