# Api to trunkate index

**URL:** <https://discuss.elastic.co/t/api-to-trunkate-index/12655>\
**Category:** Elasticsearch\
**Created:** [July 4, 2013, 5:16am UTC](https://discuss.elastic.co/t/api-to-trunkate-index/12655 "2013-07-04T05:16:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [July 4, 2013, 5:16am UTC](https://discuss.elastic.co/t/api-to-trunkate-index/12655/1 "2013-07-04T05:16:58Z")

</div>

Is anything exist to effectively and quickly delete all index data without deleting settimgs, mappings, aliases etc. so the index can be immediately reloaded

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [July 4, 2013, 7:00am UTC](https://discuss.elastic.co/t/api-to-trunkate-index/12655/2 "2013-07-04T07:00:59Z")

</div>

Hello Alex,

You can use delete by query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

It's not necessarily fast, though. It has to run the query, then delete all  
docs from there, which effectively just marks them as deleted, then  
expunges them during merging.

It should be much faster to just backup settings, mappings, aliases, etc,  
then remove the index completely and recreate it.

This is all due to the way Elasticsearch (or rather, Lucene) works. It  
stores data in segments, which are immutable. So you're always better off  
deleting the whole thing and recreating, than to work with individual  
documents.

On Thu, Jul 4, 2013 at 8:16 AM, AlexR [roytmana@gmail.com](mailto:roytmana@gmail.com) wrote:

> Is anything exist to effectively and quickly delete all index data without  
> deleting settimgs, mappings, aliases etc. so the index can be immediately  
> reloaded
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [July 4, 2013, 6:35pm UTC](https://discuss.elastic.co/t/api-to-trunkate-index/12655/3 "2013-07-04T18:35:08Z")

</div>

Exactly my point. It would be nice to have truncate index api to quickly drop and reinitialize lucene files leaving all index definitions in place. Very handy when reloading index data

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:28am UTC](https://discuss.elastic.co/t/api-to-trunkate-index/12655/4 "2017-07-06T02:28:09Z")

</div>


