# Delete all documents in an Index - Using Python

**URL:** <https://discuss.elastic.co/t/delete-all-documents-in-an-index-using-python/22247>\
**Category:** Elasticsearch\
**Created:** [February 18, 2015, 8:15pm UTC](https://discuss.elastic.co/t/delete-all-documents-in-an-index-using-python/22247 "2015-02-18T20:15:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amay\_Patil](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Amay\_Patil](https://discuss.elastic.co/u/Amay_Patil)\
**Post date:** [February 18, 2015, 8:15pm UTC](https://discuss.elastic.co/t/delete-all-documents-in-an-index-using-python/22247/1 "2015-02-18T20:15:24Z")

</div>

How can I delete all documents in an Index using Python.

Ap

--  
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/09e75c24-1fba-4529-b3a6-d29392beefa0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/09e75c24-1fba-4529-b3a6-d29392beefa0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [February 18, 2015, 10:26pm UTC](https://discuss.elastic.co/t/delete-all-documents-in-an-index-using-python/22247/2 "2015-02-18T22:26:14Z")

</div>

If you're deleting it all, why not just delete the whole index and  
re-create it? It will certainly be faster, and less taxing to the system.

If you need to preserve a mapping, download it first so you can re-upload  
it later.

--Aaron

On Wednesday, February 18, 2015 at 1:15:25 PM UTC-7, Amay Patil wrote:

> How can I delete all documents in an Index using Python.
> 
> Ap

--  
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/20c55daa-4c60-46ad-92a1-3b398c386ee5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/20c55daa-4c60-46ad-92a1-3b398c386ee5%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:31am UTC](https://discuss.elastic.co/t/delete-all-documents-in-an-index-using-python/22247/3 "2017-07-06T00:31:45Z")

</div>


