# Index template

**URL:** <https://discuss.elastic.co/t/index-template/15815>\
**Category:** Elasticsearch\
**Created:** [February 14, 2014, 7:36pm UTC](https://discuss.elastic.co/t/index-template/15815 "2014-02-14T19:36:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://discuss.elastic.co/u/san)\
**Post date:** [February 14, 2014, 7:36pm UTC](https://discuss.elastic.co/t/index-template/15815/1 "2014-02-14T19:36:32Z")

</div>

What is the importance of Index template?  
Could someone explain with an example?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b2d425bf-8204-4fa3-ad02-2a9202fb2d16%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b2d425bf-8204-4fa3-ad02-2a9202fb2d16%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 14, 2014, 8:17pm UTC](https://discuss.elastic.co/t/index-template/15815/2 "2014-02-14T20:17:52Z")

</div>

If you find yourself repeatedly creating indexes with some similar  
characteristics, then you create an index template. Whenever you create a  
new index and if a template exists that matches it, then the template will  
be applied along with whatever you have predefined inside the template. An  
example is below (taken directly from the docs -  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates)):

curl -XPUT localhost:9200/\_template/template\_1 -d '  
{  
"template" : "te\*",  
"settings" : {  
"number\_of\_shards" : 1  
},  
"mappings" : {  
"type1" : {  
"\_source" : { "enabled" : false }  
}  
}  
}  
'

The above template says, if anybody creates a new index in the future with  
a name that starts with te ("te\*"), then automatically make 1 shard for it,  
and disable the \_source field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/498f5a74-4b0f-44a3-b88c-87f2a2b8b07f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/498f5a74-4b0f-44a3-b88c-87f2a2b8b07f%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 14, 2014, 8:23pm UTC](https://discuss.elastic.co/t/index-template/15815/3 "2014-02-14T20:23:46Z")

</div>

If you find yourself repeatedly creating indexes with some similar  
characteristics, then you create an index template. Whenever you create a  
new index and if a template exists that matches it, then the template will  
be applied along with whatever you have predefined inside the template. An  
example is below (taken directly from the docs -  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates)  
):

curl -XPUT localhost:9200/\_template/template\_1 -d '  
{  
"template" : "te\*",  
"settings" : {  
"number\_of\_shards" : 1  
},  
"mappings" : {  
"type1" : {  
"\_source" : { "enabled" : false }  
}  
}  
}  
'

The above template says, if anybody creates a new index in the future with  
a name that starts with te ("te\*"), then automatically make 1 shard for it,  
create a type named type1, and disable its \_source field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/68d649d7-3df4-48a7-8832-9a42243637cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68d649d7-3df4-48a7-8832-9a42243637cb%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 14, 2014, 8:24pm UTC](https://discuss.elastic.co/t/index-template/15815/4 "2014-02-14T20:24:56Z")

</div>

If you find yourself repeatedly creating indexes with some similar  
characteristics, then you create an index template. Whenever you create a  
new index and if a template exists that matches it, then the template will  
be applied along with whatever you have predefined inside the template. An  
example is below (taken directly from the docs -  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html)):

curl -XPUT localhost:9200/\_template/template\_1 -d '  
{  
"template" : "te\*",  
"settings" : {  
"number\_of\_shards" : 1  
},  
"mappings" : {  
"type1" : {  
"\_source" : { "enabled" : false }  
}  
}  
}  
'

The above template says, if anybody creates a new index in the future with  
a name that starts with te ("te\*"), then automatically make 1 shard for it,  
create a type named type1, and disable its \_source field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/23313c6a-ac12-49a1-aa57-23e6be854ee1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/23313c6a-ac12-49a1-aa57-23e6be854ee1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://discuss.elastic.co/u/san)\
**Post date:** [February 17, 2014, 4:26am UTC](https://discuss.elastic.co/t/index-template/15815/5 "2014-02-17T04:26:17Z")

</div>

Thank you for your response.

My requirement is to create index based on some of the fields of the Actual  
Message using the template.

For example,

The content of the actual message be "Place=Austin, Time=Day". Then using  
the template i would like to create INDEX based on Place and Time.

Is this possible? If it is, how?

On Saturday, February 15, 2014 1:06:32 AM UTC+5:30, san wrote:

> What is the importance of Index template?  
> Could someone explain with an example?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1d0392f7-e00f-4eb2-b787-31d0ed3d9f9b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1d0392f7-e00f-4eb2-b787-31d0ed3d9f9b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 18, 2014, 2:26pm UTC](https://discuss.elastic.co/t/index-template/15815/6 "2014-02-18T14:26:07Z")

</div>

No, I do not believe you can make a template based on values in your data.  
However, you can always parse your document first, and then decide what to  
name your index, and then have index template match on the name that you  
use.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f8bbe52c-15a2-46da-94da-6327e636ebd5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f8bbe52c-15a2-46da-94da-6327e636ebd5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:49am UTC](https://discuss.elastic.co/t/index-template/15815/7 "2017-07-06T01:49:28Z")

</div>


