# Dynamic alias remapping for newly created index

**URL:** <https://discuss.elastic.co/t/dynamic-alias-remapping-for-newly-created-index/199389>\
**Category:** Elasticsearch\
**Created:** [September 13, 2019, 8:35am UTC](https://discuss.elastic.co/t/dynamic-alias-remapping-for-newly-created-index/199389 "2019-09-13T08:35:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![O\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/o_k/32/52424_2.png) [@O\_K](https://discuss.elastic.co/u/O_K)\
**Post date:** [September 13, 2019, 8:35am UTC](https://discuss.elastic.co/t/dynamic-alias-remapping-for-newly-created-index/199389/1 "2019-09-13T08:35:01Z")

</div>

When I create the following alias, it maps currently available indexes like `apps-2019.09.11, apps-2019.09.12`

```
curl -XPOST 'localhost:9200/_aliases' -H 'Content-Type: application/json' -d'
{
    "actions" : [
        { "add" : { "index" : "apps*", "alias" : "backend_apps" } }
    ]
}
'

-XGET "http://localhost:9200/_cat/aliases"
java_apps apps-2019.09.11 - - -
java_apps apps-2019.09.12 - - -

```

When the new index gets created e.g. `apps-2019.09.13`, the alias doesn't map to it automatically.  
So, if I run the above POST query the second time, it solves the problem.

Question: is there any option to make alias gets mapped automatically to newly created indexes based on pattern `apps*`

I obviously could do this via script/cron/daemonset, but wondering if there is a native option.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 14, 2019, 9:42am UTC](https://discuss.elastic.co/t/dynamic-alias-remapping-for-newly-created-index/199389/2 "2019-09-14T09:42:45Z")

</div>

Add the alias to your index template and it will be added when the index is created.

---

<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:** [October 12, 2019, 9:43am UTC](https://discuss.elastic.co/t/dynamic-alias-remapping-for-newly-created-index/199389/3 "2019-10-12T09:43:34Z")

</div>

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