# \_template vs \_index\_template

**URL:** <https://discuss.elastic.co/t/template-vs-index-template/274730>\
**Category:** Elasticsearch\
**Created:** [June 2, 2021, 9:26am UTC](https://discuss.elastic.co/t/template-vs-index-template/274730 "2021-06-02T09:26:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordi\_Cabre1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordi_cabre1/32/79638_2.png) [@Jordi\_Cabre1](https://discuss.elastic.co/u/Jordi_Cabre1)\
**Post date:** [June 2, 2021, 9:26am UTC](https://discuss.elastic.co/t/template-vs-index-template/274730/1 "2021-06-02T09:26:15Z")

</div>

I've just realized that ES has a `_/_template` and a `_/_index_template`.

What are they for?

I was using code:

```auto
PutIndexTemplateRequest ngramTemplate = new PutIndexTemplateRequest("ngram-template")
	.patterns(Arrays.asList("resourcetable-*", "termconcept-*"))
	.settings(Settings.builder().put("index.max_ngram_diff", 50));

```

I didn't understand why my `ngram-template` didn't appear on `_/_index_template`.

After that, I was looking on `_/_template`.....

Which is the difference between them?

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [June 2, 2021, 12:10pm UTC](https://discuss.elastic.co/t/template-vs-index-template/274730/2 "2021-06-02T12:10:09Z")

</div>

Hello Jordi,

Welcome to this community 🎉

The \_template API belongs to the old legacy templates. This was a bit more complex as you can have multiple legacy templates for the same index(e.g. a very general template matching all indices `*`, a template for all filebeat indices `filebeat-*` and a template for the current filebeat version `filebeat-7.13-*`). See [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html) for details.

The newer `_index_template` API solves this by only applying only the template with the highest priority. In order to be able to reuse specific components there is a separe API `_component_template` to create reusable components which can be integrated into an index template. See [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html) for details.

This difference is also reflected in Kibana where the top list of the index templates are the newer templates and the legacy templates are listed at the bottom of the page.

If you are asking which one to use I would advise to use the newer version as they are easier to manage (in my opinion) and my guess is that the legacy templates will be removed sooner or later. But if you have lots of templates which would migration hard you may keep the old templates (just make sure that your templates do not collide with the default templates created by Elastic `logs-*-*`, `metrics-*-*`, `synthetics-*-*`).

Best regards  
Wolfram

---

<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:** [June 30, 2021, 12:10pm UTC](https://discuss.elastic.co/t/template-vs-index-template/274730/3 "2021-06-30T12:10:31Z")

</div>

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