# Purge data within a date range from an Elasticsearch database

**URL:** <https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763>\
**Category:** Elasticsearch\
**Created:** [July 5, 2016, 3:46pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763 "2016-07-05T15:46:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwelber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cwelber/32/5268_2.png) [@cwelber](https://discuss.elastic.co/u/cwelber)\
**Post date:** [July 5, 2016, 3:46pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763/1 "2016-07-05T15:46:57Z")

</div>

How could I purge everything older than a date say (x/x/xxxx) from an Elasticsearch database?

Thanks!

---

<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:** [July 5, 2016, 3:59pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763/2 "2016-07-05T15:59:59Z")

</div>

There is an efficient way and an inefficient way. The efficient way is to name your index with a date or week in it and delete the entire index when you don't need it any more. The inefficient way is to use the delete-by-query plugin with a date range. The first option will immediately free up space. The second one will free up space eventually, but how and when it does it is quite complex.

---

<div class="post-metadata">

**Author:** ![cwelber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cwelber/32/5268_2.png) [@cwelber](https://discuss.elastic.co/u/cwelber)\
**Post date:** [July 5, 2016, 4:52pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763/3 "2016-07-05T16:52:52Z")

</div>

I was trying to use curator to do this automatically.

---

<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:** [July 5, 2016, 8:47pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763/4 "2016-07-05T20:47:36Z")

</div>

Is that not working?

(Also, ES is not a database)

---

<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:37pm UTC](https://discuss.elastic.co/t/purge-data-within-a-date-range-from-an-elasticsearch-database/54763/5 "2017-07-05T22:37:48Z")

</div>


