# How to delete all data from an index without deleting the index?

**URL:** <https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276>\
**Category:** Elasticsearch\
**Created:** [August 17, 2020, 4:10pm UTC](https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276 "2020-08-17T16:10:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kovacsbv](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@kovacsbv](https://discuss.elastic.co/u/kovacsbv)\
**Post date:** [August 17, 2020, 4:10pm UTC](https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276/1 "2020-08-17T16:10:55Z")

</div>

Hello,

I am looking for a **simple** and **efficient** way to delete all data from an index without deleting the index. This is known as a truncate in SQL parlance.

The rationale is that I want to clear the data while leaving typing and permissions intact. Both typing and permissions are complicated and it's not something I want to do repeatedly anyway.

[This posting](https://discuss.elastic.co/t/delete-all-data-from-index-without-deleting-index/87661) asks the same question and goes like this: "You can use delete by query, but it's seriously inefficient." "What if I don't care that it's inefficient?" "Why not just delete it and repopulate?"

So I open a [feature request](https://github.com/elastic/elasticsearch/issues/57077) which gets summarily closed with "use delete by query". This is a fundamental feature which deserves a good answer.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 17, 2020, 5:08pm UTC](https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276/2 "2020-08-17T17:08:25Z")

</div>

Create an index template with settings and mappings. You Dan the delete the index and be sure it is recreated with correct mappings when it is recreated. This s the closest to a truncate you will get.

---

<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 17, 2020, 10:30pm UTC](https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276/3 "2020-08-17T22:30:44Z")

</div>

Welcome to our community! 😃

> [@kovacsbv](#):
>
> I am looking for a **simple** and **efficient** way to delete all data from an index without deleting the index. This is known as a truncate in SQL parlance.

As you've seen, having it both of these is not possible in Elasticsearch, it's just the way that it works.

Your best option is to follow Christian's suggestions.

---

<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 14, 2020, 10:30pm UTC](https://discuss.elastic.co/t/how-to-delete-all-data-from-an-index-without-deleting-the-index/245276/4 "2020-09-14T22:30:52Z")

</div>

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