# How to apply different index template in single index?

**URL:** <https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097>\
**Category:** Elasticsearch\
**Created:** [August 3, 2016, 11:15am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097 "2016-08-03T11:15:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 3, 2016, 11:15am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/1 "2016-08-03T11:15:50Z")

</div>

Hi!

I am using logstash (ver 5.0.0 alpha 4) to insert data into elasticsearch.

I would like to know whether it is possible to apply different index template according to type name but in same index.

[https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html)

So for example,

Logstash inserts documents as below types. All type has common fields and field types.

Index type fields and type  
idx1 apple field : keyword  
idx1 orange field : keyword  
idx1 banana field : keyword

Is it possible to create different index templates?

---

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [August 3, 2016, 11:19am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/2 "2016-08-03T11:19:47Z")

</div>

You can define multiple search types for a single index, see [https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-index-multi-type.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-index-multi-type.html)

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 3, 2016, 11:26am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/3 "2016-08-03T11:26:13Z")

</div>

Hi !

Sorry I didnt make my explanation clear.

I was mentioning about index template.

[https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html)

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [August 3, 2016, 12:09pm UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/4 "2016-08-03T12:09:57Z")

</div>

There is no way, because index template is applied only at **index creation time**.  
It is not related type name.

However you **can** create different index templates.  
Multi index templates can be applied to one index.  
[https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html#multiple-templates](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html#multiple-templates)

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 3, 2016, 1:32pm UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/5 "2016-08-03T13:32:02Z")

</div>

Hello Jun-san.

What I thought was since you specify **type** , elasticsearch will also use the type for matching template.

I should have read definitive guide.

[https://www.elastic.co/guide/en/elasticsearch/guide/2.x/mapping.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/mapping.html)

I cannot have same field name with different type anyway.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 4, 2016, 8:11am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/6 "2016-08-04T08:11:46Z")

</div>

Be careful of this - [https://www.elastic.co/blog/index-vs-type](https://www.elastic.co/blog/index-vs-type)

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 4, 2016, 8:56am UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/7 "2016-08-04T08:56:30Z")

</div>

@warkolm

Thank you for the reply.

I will look into it.

---

<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, 10:30pm UTC](https://discuss.elastic.co/t/how-to-apply-different-index-template-in-single-index/57097/8 "2017-07-05T22:30:10Z")

</div>


