PUT aliases for multiple index

Hello.
I am changing the organization of the indexes in my cluster. I have added an alias to the template and from now all indexes I need will get a correct view alias.
But I have a bunch (1k of them) without view aliases. When I try to use * it's not working. Is there another way than adding an alias for each one of them ?

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "aliaspattern01-*",
        "alias": "01_view_alias"
      }
    }
  ]
}

Hi,

that the index field in the add action does not support wildcard patterns. The index field expects a single index name, not a pattern.

To add an alias to multiple indices, you'll need to execute the add action for each index individually.

Regards

That's not comforting because until now i have like 3k of them so maybe there is some partial resolution for this ? Maybe a script in bash with curl command on it ?

There is nothing native, but it can be easily automated.

You can use the GET _cat/indices API to get a list of your indices and from this list write a bash script with curl to make the requests to add the alias.

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