# Best practice for expiring data in v6

**URL:** <https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386>\
**Category:** Elasticsearch\
**Created:** [November 28, 2017, 12:29pm UTC](https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386 "2017-11-28T12:29:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clarkeash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clarkeash/32/24768_2.png) [@clarkeash](https://discuss.elastic.co/u/clarkeash)\
**Post date:** [November 28, 2017, 12:29pm UTC](https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386/1 "2017-11-28T12:29:33Z")

</div>

Perviously we had the \_ttl option (i've not used it) but now thats gone what is the recommended way to delete old data?

My data will have a timestamp, so I could regularly call the api and delete records past a certain date, but wasnt sure if there was a better way of doing this?

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 28, 2017, 12:49pm UTC](https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386/2 "2017-11-28T12:49:33Z")

</div>

You can use Delete By Query API and run that every x minutes/day/xxx depending on your needs.

But removing a lot of data is not ideal. Better to use timebased indices and simply drop an index entirely when its data is too old.

HTH

---

<div class="post-metadata">

**Author:** ![clarkeash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clarkeash/32/24768_2.png) [@clarkeash](https://discuss.elastic.co/u/clarkeash)\
**Post date:** [November 28, 2017, 12:58pm UTC](https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386/3 "2017-11-28T12:58:42Z")

</div>

I will be inserting and therefore deleting around 150'000 documents per day, so time based indicies will probably be a better option.

I assume having a new index per day would be adequate.

---

<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:** [December 26, 2017, 12:58pm UTC](https://discuss.elastic.co/t/best-practice-for-expiring-data-in-v6/109386/4 "2017-12-26T12:58:48Z")

</div>

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