# Auto Index and auto deletion of index

**URL:** https://discuss.elastic.co/t/auto-index-and-auto-deletion-of-index/221484
**Category:** Elasticsearch
**Created:** [February 28, 2020, 8:05pm UTC](https://discuss.elastic.co/t/auto-index-and-auto-deletion-of-index/221484 "2020-02-28T20:05:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![somebody](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@somebody](https://discuss.elastic.co/u/somebody)
#### Post date: [February 28, 2020, 8:05pm UTC](https://discuss.elastic.co/t/auto-index-and-auto-deletion-of-index/221484/1 "2020-02-28T20:05:07Z")

</div>

Hi,

We have the following requirement:  
Every month a new index(collection) have to be created: comany\_details-\<year\_month\> in ES cluster.  
We need to delete older index which is greater than 2 Months.  
Example:  
company\_details-2019-12 (delete this index)  
company\_details-2020-01 (retain this index)  
company\_details-2020-02 (retain this index)  
We could create an alias company\_details and point it to the current Month index (so that we could do indexing/querying). This also have to be updated every Month automatically.

How can we setup ES so that this would be done automatically?

Thanks,  
Somebody.

---

<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 27, 2020, 8:05pm UTC](https://discuss.elastic.co/t/auto-index-and-auto-deletion-of-index/221484/2 "2020-03-27T20:05:08Z")

</div>

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