ISM rollover and alias

I have ISM policy to perform rollover

{
    "policy": {
        "policy_id": "my_ism",
        "description": "my_ism",
        "last_updated_time": 1629016126477,
        "schema_version": 1,
        "error_notification": null,
        "default_state": "ReadWrite",
        "states": [
            {
                "name": "ReadWrite",
                "actions": [
                    {
                        "rollover": {
                            "min_index_age": "3m"
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "ReadOnly",
                        "conditions": {
                            "min_index_age": "3m"
                        }
                    }
                ]
            },
            {
                "name": "ReadOnly",
                "actions": [
                    {
                        "read_only": {}
                    }
                ],
                "transitions": [
                    {
                        "state_name": "Delete",
                        "conditions": {
                            "min_index_age": "5h"
                        }
                    }
                ]
            },
            {
                "name": "Delete",
                "actions": [
                    {
                        "delete": {}
                    }
                ],
                "transitions": []
            }
        ],
        "ism_template": [
            {
                "index_patterns": [
                    "my_index*"
                ],
                "priority": 100,
                "last_updated_time": 1628845455505
            }
        ]
    }
}

In addition i have an alias for the first index

{
"my_index-000001" : {
    "aliases" : {
      "my_index" : { }
    }
  }
}

The ISM rollover the index and new one is created , but the alias “my_index” now points to the new index “my_index-000002” , and the old index has no alias. With ILM the alias is exist for both indices , but ISM removes alias for the old index . Is it expected ?

try to set rollover_alias in index template

For rollover, I usually doing the following steps before indexing data.

  1. Set policy and rollover alias in index template
PUT _template/your_index_template
{
  "index_patterns" : [
  	"your_index-*"
  ],
  "settings": {
    "opendistro.index_state_management.policy_id": "max-5-doc",
    "opendistro.index_state_management.rollover_alias": "your_index_alias"
  }
}
  1. Init first index
PUT your_index-000001
{
  "aliases": {
	"your_index_alias": {
            "is_write_index": true
     }
  }
}