ILM rollover when max_docs reached

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 :

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

Then I created a template :

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 :

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,

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.