# Index Mapping v/s Template

**URL:** <https://discuss.elastic.co/t/index-mapping-v-s-template/184741>\
**Category:** Elasticsearch\
**Created:** [June 7, 2019, 10:52am UTC](https://discuss.elastic.co/t/index-mapping-v-s-template/184741 "2019-06-07T10:52:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prabhav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prabhav/32/64630_2.png) [@Prabhav](https://discuss.elastic.co/u/Prabhav)\
**Post date:** [June 7, 2019, 10:52am UTC](https://discuss.elastic.co/t/index-mapping-v-s-template/184741/1 "2019-06-07T10:52:58Z")

</div>

Can someone explain the major points of difference between Index Mapping and Template, since many examples described were not clear enough, Can someone explain difference with an example?

---

<div class="post-metadata">

**Author:** ![thekm1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thekm1/32/35926_2.png) [@thekm1](https://discuss.elastic.co/u/thekm1)\
**Post date:** [June 7, 2019, 12:39pm UTC](https://discuss.elastic.co/t/index-mapping-v-s-template/184741/2 "2019-06-07T12:39:17Z")

</div>

Hi @Prabhav

#### Index -Template

As the name says this is template which an index can take. you can predefine all settings like

- primary shards
- number of replicas
- ...

And you can also define a index-mapping inside a template. (i will get to it below)

Then you also can add a patterns of indices name where theese templates should be activated. So example index-pattern in index-templates says `test-*`. So each index with names like test-1, test-abc etc will take the settings

#### Index-Mapping

Think about a document. This is a json file which lands inside an index. And a json file has attribute and values. And know for analysing elasticsearch needs to know wihch attribute contains what type of value(is it a text, or a keyword or a timestamp). So this can be defined in an index-mapping.

Conclusion: index mapping contains information about what kind of values is inside an index. An Index-template contains predefines index options(settings, mappings, analyzer) which will get adapted to an index on creation.

Helped?

---

<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, 2019, 12:39pm UTC](https://discuss.elastic.co/t/index-mapping-v-s-template/184741/3 "2019-07-05T12:39:23Z")

</div>

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