# Automatic deletion of read only indices with 0 documents

**URL:** <https://discuss.elastic.co/t/automatic-deletion-of-read-only-indices-with-0-documents/249378>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [September 21, 2020, 2:19pm UTC](https://discuss.elastic.co/t/automatic-deletion-of-read-only-indices-with-0-documents/249378 "2020-09-21T14:19:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjedynak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mjedynak/32/75945_2.png) [@mjedynak](https://discuss.elastic.co/u/mjedynak)\
**Post date:** [September 21, 2020, 2:19pm UTC](https://discuss.elastic.co/t/automatic-deletion-of-read-only-indices-with-0-documents/249378/1 "2020-09-21T14:19:56Z")

</div>

I have index lifecycle policy (hot phase 1 month -\> warm phase 1 year -\> delete phase)  
My index has 2 primary shards + 1 replica (4 shards in total).  
Sometimes it happens that my index has 0 documents and it rolls over after 1 month to warm phase and becomes read only.  
General advice is to have 1GB per 20 shards. Should my index in warm phase (that has 0 documents and 4 shards) also be taken into account in this calculation ?  
Is it possible to automatically delete indices that have 0 documents and are in warm phase and are read only?  
Does shrink or force merge help a bit in such situation?

---

<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:** [September 21, 2020, 8:57pm UTC](https://discuss.elastic.co/t/automatic-deletion-of-read-only-indices-with-0-documents/249378/2 "2020-09-21T20:57:59Z")

</div>

Welcome to our community! 😃

An empty shard is always wasteful. There's no logic in ILM to let you say "if 0 docs then delete", so you'd need something external to do that.

You can also create a feature request on GitHub for ILM to handle this in a future version.

---

<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:** [October 19, 2020, 8:57pm UTC](https://discuss.elastic.co/t/automatic-deletion-of-read-only-indices-with-0-documents/249378/3 "2020-10-19T20:57:59Z")

</div>

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