# How multiple indexes correspond to multiple aliases in a template

**URL:** <https://discuss.elastic.co/t/how-multiple-indexes-correspond-to-multiple-aliases-in-a-template/203403>\
**Category:** Elasticsearch\
**Created:** [October 14, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-multiple-indexes-correspond-to-multiple-aliases-in-a-template/203403 "2019-10-14T07:57:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenius](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenius/32/55762_2.png) [@jenius](https://discuss.elastic.co/u/jenius)\
**Post date:** [October 14, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-multiple-indexes-correspond-to-multiple-aliases-in-a-template/203403/1 "2019-10-14T07:57:54Z")

</div>

Every 30 seconds, the system status will be stored in the ES. The index name is, for example, i\_index-2019-10-10. The aggregation will be done every 5 minutes. The data of this table will be summarized into the 5-minute table. The index name is for example: i\_index- 5m-2019-10-10, I want to use a template definition, i\_index-20\* corresponds to the alias a\_index, and i\_index-5m-\* corresponds to the alias a\_index-5m.  
How should the template file be written?  
Elasticsearch version :7.3.1  
1.I tried to write like this, it doesn't work

```json
 PUT _template/t_ceshi
{
 "order": 0,
 "index_patterns": ["i_ceshi-*"],
 "settings": {
   "index": {
     "number_of_shards": "1",
     "number_of_replicas": "0",
     "refresh_interval": "5s"
   }
 },
 "mappings": {
   "dynamic": false,
   "properties": {
     
   }
 },
 "aliases": {
   "actions" : [
       { "add" : { "index" : "i_ceshi-20*", "alias" : "a_ceshi" } },
       { "add" : { "index" : "i_ceshi-5m-*", "alias" : "a_ceshi-5m" } }
   ]
 }
}

```

2.I also tried to write like this, it doesn’t work either.

```json
PUT _template/t_ceshi
 {
   "order": 0,
   "index_patterns": ["i_ceshi-*"],
   "settings": {
     "index": {
       "number_of_shards": "1",
       "number_of_replicas": "0",
       "refresh_interval": "5s"
     }
   },
   "mappings": {
     "dynamic": false,
     "properties": {
       
   }
   },
   "aliases": {
     "a_ceshi": {"index":"i_ceshi-20*"},
     "a_ceshi-5m": {"index":"i_ceshi-5m-*"}
   }
 }

```

---

<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:** [November 11, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-multiple-indexes-correspond-to-multiple-aliases-in-a-template/203403/2 "2019-11-11T07:57:56Z")

</div>

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