# Elasticsearch 1.7: specify multiple index template patterns?

**URL:** https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196
**Category:** Elasticsearch
**Created:** [February 18, 2016, 9:26pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196 "2016-02-18T21:26:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)
#### Post date: [February 18, 2016, 9:26pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/1 "2016-02-18T21:26:26Z")

</div>

I want to use the same template to specify mappings for indices with different patterns. Must I create a separate template file for each one? Attempts to specify more than one pattern have met with failure:

**Approach 1**  
This does not seem to match either pattern1 or pattern2:

```
{ ...
   "template": "pattern1*|pattern2*"
   ...}
{code}

```

**Approach 2**  
This seems to take the last "template" that was specified.

```
{ ...
  "template": "pattern1",
   "template":"pattern2"
   ...
}

```

**Approach 3**  
This surprisingly seems to take the last item in the list and ignores the first:

```
{ ...
  "template": ["pattern1*", "pattern2*"]
 ... }

```

Is there a way to do this?

---

<div class="post-metadata">

### Author: ![Jeferson\_Martins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeferson_martins/32/5849_2.png) [@Jeferson\_Martins](https://discuss.elastic.co/u/Jeferson_Martins)
#### Post date: [February 18, 2016, 9:28pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/2 "2016-02-18T21:28:46Z")

</div>

In my case, I use only one template with:  
template: "\*"  
and specify the order of "execution"

---

<div class="post-metadata">

### Author: ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)
#### Post date: [February 18, 2016, 9:35pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/3 "2016-02-18T21:35:01Z")

</div>

Can you give a simple example? Are you saying you just have various types not used across multiple indices in the same file?

```
{... "template": "*" ...
      "type1" : { ... }
      "type2" : {... }
 ...}
```

---

<div class="post-metadata">

### Author: ![Jeferson\_Martins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeferson_martins/32/5849_2.png) [@Jeferson\_Martins](https://discuss.elastic.co/u/Jeferson_Martins)
#### Post date: [February 18, 2016, 9:38pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/4 "2016-02-18T21:38:07Z")

</div>

You want specify diferents schemas in same template?

I dont understand your example with type1 and type2.

In my case, I use the same schema for all indices. It is that you want?

---

<div class="post-metadata">

### Author: ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)
#### Post date: [February 18, 2016, 9:49pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/5 "2016-02-18T21:49:16Z")

</div>

I have different types which may have different fields, so index1 may have different fields than index2. So I think my use case could be a little different than the one you've described.

---

<div class="post-metadata">

### Author: ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)
#### Post date: [February 19, 2016, 3:04pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/6 "2016-02-19T15:04:31Z")

</div>

Does anyone have a different thought on this?

---

<div class="post-metadata">

### Author: ![Jeferson\_Martins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeferson_martins/32/5849_2.png) [@Jeferson\_Martins](https://discuss.elastic.co/u/Jeferson_Martins)
#### Post date: [February 19, 2016, 3:59pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/7 "2016-02-19T15:59:45Z")

</div>

Now I think if you have diferent types make sense have diferent templates.

There's the attribute order that you can specify that template will be use first

---

<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: [July 5, 2017, 11:14pm UTC](https://discuss.elastic.co/t/elasticsearch-1-7-specify-multiple-index-template-patterns/42196/8 "2017-07-05T23:14:51Z")

</div>


