# Time based indexes and automatic deletion of created indexes

**URL:** <https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990>\
**Category:** Elasticsearch\
**Created:** [April 28, 2017, 9:31am UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990 "2017-04-28T09:31:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamsameer](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@iamsameer](https://discuss.elastic.co/u/iamsameer)\
**Post date:** [April 28, 2017, 9:31am UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990/1 "2017-04-28T09:31:39Z")

</div>

Hello,

I am planning to upgrade ES 2.3 to 5.3. We are using Nest client and Sense(chrome extension) to see data.  
Since ttl is removed in ES 5.3, I am looking alternative way for it.

I am looking for solution like, index will be created with expiration time and after time(i.e. which we have set at the time of index creation) will be automatically deleted. No need to explicitly run the query or code to delete the created index manually.  
Is there any way to achieve this.  
Please help.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 28, 2017, 1:13pm UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990/2 "2017-04-28T13:13:45Z")

</div>

This is a pretty common situation people do. The general way to deal with this is with [curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/installation.html) and setting up time-based indices (e.g. 1 per day). Curator has a [`delete_indices`](https://www.elastic.co/guide/en/elasticsearch/client/curator/5.0/ex_delete_indices.html) action, and the example does more or less exactly what you're looking for: deleting an index matching some pattern that is older than N days.

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [April 28, 2017, 2:01pm UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990/3 "2017-04-28T14:01:22Z")

</div>

> [@iamsameer](#):
>
> No need to explicitly run the query or code to delete the created index manually.Is there any way to achieve this.

To be clear, the answer to this question is no. There is no such solution within Elasticsearch. The APIs are provided so you can roll your own. As @shanec mentioned, [Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/installation.html) provides a way to automate this (and many other actions) with cron.

---

<div class="post-metadata">

**Author:** ![iamsameer](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@iamsameer](https://discuss.elastic.co/u/iamsameer)\
**Post date:** [May 8, 2017, 11:09am UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990/4 "2017-05-08T11:09:18Z")

</div>

Thanks for your reply. I will try with other 2 options.

---

<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:** [June 5, 2017, 11:21am UTC](https://discuss.elastic.co/t/time-based-indexes-and-automatic-deletion-of-created-indexes/83990/5 "2017-06-05T11:21:12Z")

</div>

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