_template vs _index_template

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

What are they for?

I was using code:

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?

Hello Jordi,

Welcome to this community :tada:

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 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 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

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