2 aliases to 1 index with rollover

Hi,

I want to define two aliases to index with rollover.

I have set the following:


PUT _ilm/policy/policy1
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_primary_shard_size": "40gb"
          }
        }
      },
      "delete": {
        "min_age": "7d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}
POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "index1-2022.10.18-000001",
        "alias": "alias1",
        "is_write_index": true
      }
    },
    {
      "add": {
        "index": "index1-2022.10.18-000001",
        "alias": "alias2"
      }
    }
]
}

After rollover is performed and new index created: index1-2022.10.18-000002, I see that only alias1 assigned to it, without alias2.

What need to be done in order that alias2 will be assigned as well to the new index.

Thanks...

You need to add the second alias using an index template, so when your new index is created, it will get the alias.

I want to define both.

I have defined in index template alias1. Can't define both.

PUT /_index_template/index1_template
{
  "version": 1, 
  "index_patterns": [
    "*index1*"
  ],
  "priority": 2,
  "template": {
    "settings": {
      "index.lifecycle.name": "policy1",
      "index.lifecycle.rollover_alias": "alias1",
      "index.lifecycle.parse_origination_date": true,
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "refresh_interval": "30s",
      "index.codec": "best_compression"
    }
  },
  "composed_of":["component_template"]
}

You can, you defined the writing alias, you can define many other read alias as you want.

You need to add an aliases block to your template as per defined in the documentation.

Just add this inside the template object and after the settings object:

"aliases" : {
        "alias2" : {}
}

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