# Creating and Deleting Indexes || Watcher

**URL:** <https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [February 9, 2018, 4:38pm UTC](https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275 "2018-02-09T16:38:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpandey](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mpandey](https://discuss.elastic.co/u/mpandey)\
**Post date:** [February 9, 2018, 4:38pm UTC](https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275/1 "2018-02-09T16:38:53Z")

</div>

Hi Everyone,

I am working on purging the old data in elasticsearch. I was wondering what is the best way to implement such a job. I have to delete all the documents which are older than 3 months and this has to repeated every 3 months. As per the documentation it is advised to delete the index itself( as it is computationally efficient) but in this case I am not sure how am I supposed to recreate the index.

Can I use the watcher to implement such a job? Will it be efficient enough? Or should I take some other alternative?

Thanks!

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [February 9, 2018, 10:52pm UTC](https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275/2 "2018-02-09T22:52:14Z")

</div>

Hi Madhav,

You can use Watcher to do what you're trying to do. I would give it a shot and see if the performance is fast enough for your needs. If it isn't you could also try reindexing your data so that each index contains documents from a single day. Then you can use our [Curator tool](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/about.html) to [select indices based on age](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/filtertype_age.html) and then [delete them](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/delete_indices.html).

Hope this helps,  
CJ

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 12, 2018, 9:04am UTC](https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275/3 "2018-02-12T09:04:24Z")

</div>

+1 on CJs advice on using curator for this - for now. I think it would be easier to handle, than a long running watch running a `delete by query` statement.

Would it be easier to have monthly indices, and then just delete the old one? You can just search across all of them when you execute a search.

--Alex

---

<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:** [March 12, 2018, 9:04am UTC](https://discuss.elastic.co/t/creating-and-deleting-indexes-watcher/119275/4 "2018-03-12T09:04:26Z")

</div>

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