# Delete query \[without effecting its schema\]

**URL:** <https://discuss.elastic.co/t/delete-query-without-effecting-its-schema/57787>\
**Category:** Elasticsearch\
**Created:** [August 11, 2016, 10:01am UTC](https://discuss.elastic.co/t/delete-query-without-effecting-its-schema/57787 "2016-08-11T10:01:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niteesh](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Niteesh](https://discuss.elastic.co/u/Niteesh)\
**Post date:** [August 11, 2016, 10:01am UTC](https://discuss.elastic.co/t/delete-query-without-effecting-its-schema/57787/1 "2016-08-11T10:01:01Z")

</div>

Hi

Can anyone tell me the solution of deleting all the records in the index without effecting the schema(index).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 11, 2016, 12:01pm UTC](https://discuss.elastic.co/t/delete-query-without-effecting-its-schema/57787/2 "2016-08-11T12:01:21Z")

</div>

The slow way is with delete by query. It'll work. The fast way is to delete  
the index and recreate it. The best way to do that without any time where  
the index doesn't exist is to create a new index and swap an alias from the  
old index to the new index. You have to be using an alias for the old  
index, but that is a useful practice anyway.

---

<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 5, 2017, 10:28pm UTC](https://discuss.elastic.co/t/delete-query-without-effecting-its-schema/57787/3 "2017-07-05T22:28:25Z")

</div>

Closed on July 5, 2017, 10:28pm UTC


