# PUT aliases for multiple index

**URL:** https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654
**Category:** Kibana
**Created:** [January 9, 2024, 12:56pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654 "2024-01-09T12:56:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![elk1985](https://avatars.discourse-cdn.com/v4/letter/e/58956e/32.png) [@elk1985](https://discuss.elastic.co/u/elk1985)
#### Post date: [January 9, 2024, 12:56pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654/1 "2024-01-09T12:56:16Z")

</div>

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 ?

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

```

---

<div class="post-metadata">

### Author: ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)
#### Post date: [January 9, 2024, 5:24pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654/2 "2024-01-09T17:24:01Z")

</div>

> [@elk1985](#):
>
> 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 ?
> 
> ```auto
> 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

---

<div class="post-metadata">

### Author: ![elk1985](https://avatars.discourse-cdn.com/v4/letter/e/58956e/32.png) [@elk1985](https://discuss.elastic.co/u/elk1985)
#### Post date: [January 31, 2024, 12:27pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654/3 "2024-01-31T12:27:05Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [January 31, 2024, 2:02pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654/4 "2024-01-31T14:02:53Z")

</div>

> [@elk1985](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 28, 2024, 2:03pm UTC](https://discuss.elastic.co/t/put-aliases-for-multiple-index/350654/5 "2024-02-28T14:03:38Z")

</div>

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