# ILM rollover when max\_docs reached

**URL:** <https://discuss.elastic.co/t/ilm-rollover-when-max-docs-reached/360455>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [May 29, 2024, 11:25am UTC](https://discuss.elastic.co/t/ilm-rollover-when-max-docs-reached/360455 "2024-05-29T11:25:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent2mots](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vincent2mots/32/55226_2.png) [@vincent2mots](https://discuss.elastic.co/u/vincent2mots)\
**Post date:** [May 29, 2024, 11:25am UTC](https://discuss.elastic.co/t/ilm-rollover-when-max-docs-reached/360455/1 "2024-05-29T11:25:40Z")

</div>

Hi experts!

I'm exploring ILM capabilities of Elasticsearch and I run some tests which are not okay.

I would like to create a ILM policy which would create a new index each time the previous one reached 30 documents.

I then started by creating the new policy :

```auto
PUT _ilm/policy/test_policy_30_documents
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_docs": "30"
          }
        }
      }
    }
  }
}

```

Then I created a template :

```auto
PUT _template/template_test_ilm
{
  "index_patterns": ["test_ilm*"],
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0, 
    "index.lifecycle.name": "test_policy_30_documents",
    "index.lifecycle.rollover_alias": "test_ilm"
  }
}

```

And finally a first index using the previous alias :

```auto
PUT test_ilm-000001
{
  "aliases": {
    "test_ilm": {
      "is_write_index": true
    }
  }
}

```

However it doesn't seem to work. When I get to 30 documents, it keeps adding documents to the index and it is not creating a new one.

I was expecting it to create a new index test\_ilm-000002 and so on

What am I missing?

Best regards,

---

<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:** [May 29, 2024, 11:57am UTC](https://discuss.elastic.co/t/ilm-rollover-when-max-docs-reached/360455/2 "2024-05-29T11:57:54Z")

</div>

> [@vincent2mots](#):
>
> I would like to create a ILM policy which would create a new index each time the previous one reached 30 documents.

The default settings for ILM are set up for realistic workloads. It therefore only checks for rollover every 10 minutes or so. This is perfect for real scenarios but means that small scale unrealistic tests do not work as expected.

Either run a more realistic test or change the settings to something that is not suitable for real-world use cases.
