# Pruning Indexes with 0 documents

**URL:** <https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172>\
**Category:** Elasticsearch\
**Created:** [August 24, 2020, 6:47pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172 "2020-08-24T18:47:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![akrzos](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@akrzos](https://discuss.elastic.co/u/akrzos)\
**Post date:** [August 24, 2020, 6:47pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/1 "2020-08-24T18:47:11Z")

</div>

Hello,

I am looking for the best method to prune indexes with 0 documents.

After we migrated to ILM, we have a few indexes which rollover with 0 documents and this can cause an in-balance across a large cluster where several nodes end up with many shards with 0 documents but not much space utilized as other nodes end up with fewer shards and much more disk utilization. I can't find if we can make an index in delete phase skip `min_age` if it has 0 documents.

Thanks!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 24, 2020, 6:57pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/2 "2020-08-24T18:57:06Z")

</div>

Why do you end up with empty indices when using rollover? Are you creating too many small specialized indices? Have you set the max age too low?

---

<div class="post-metadata">

**Author:** ![akrzos](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@akrzos](https://discuss.elastic.co/u/akrzos)\
**Post date:** [August 24, 2020, 7:20pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/3 "2020-08-24T19:20:27Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> Why do you end up with empty indices when using rollover? Are you creating too many small specialized indices? Have you set the max age too low?

Hi Christian,

We have several indexes that have 0 docs so far as we have several "Retention" periods for filebeat logging data. Some of those are unused at the moment. We roll over indexes when the shards are approximately 50GiB in size or typically 24 hours old. This is to mainly match previous daily index rollover behavior of Elasticsearch.

Anyhow it looks like I found a potential solution being that I can run curator to prune empty indexes that are an age \> the rollover period so we don't accidentally prune the hot index.

---

<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:** [August 24, 2020, 9:58pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/4 "2020-08-24T21:58:34Z")

</div>

> [@akrzos](#):
>
> We roll over indexes when the shards are approximately 50GiB in size or typically 24 hours old. This is to mainly match previous daily index rollover behavior of Elasticsearch.

I would just remove the time based rollover and keep the size one in that case.

> [@akrzos](#):
>
> Anyhow it looks like I found a potential solution being that I can run curator to prune empty indexes that are an age \> the rollover period so we don't accidentally prune the hot index.

Curator won't run if it detects ILM though ([by default](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ilm-and-curator.html)).

---

<div class="post-metadata">

**Author:** ![akrzos](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@akrzos](https://discuss.elastic.co/u/akrzos)\
**Post date:** [August 25, 2020, 1:49pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/5 "2020-08-25T13:49:57Z")

</div>

> [@warkolm](#):
>
> I would just remove the time based rollover and keep the size one in that case.

That effectively makes these no long time-series data, though it would keep the number of 0 doc indexes down to the minimum. It would also permit some time-series data to live much longer than it's desired retention period.

> [@warkolm](#):
>
> Curator won't run if it detects ILM though ([by default](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ilm-and-curator.html)).

Yup we can just enable it to delete those though.

---

<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:** [September 22, 2020, 1:50pm UTC](https://discuss.elastic.co/t/pruning-indexes-with-0-documents/246172/6 "2020-09-22T13:50:11Z")

</div>

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