Please help me to understand mapping templates

In documentation we have information that:

"index templates are deprecated and will be replaced by the composable templates".

But when we enter composable templates documentation we have statement:

"You cannot directly apply a component template to a data stream or index. To be applied, a component template must be included in an index template’s"

So I understand nothing; index templates are replaced by component templates but component templates require... index templates.

So now what will be correct syntax to apply mapping template on indices?
Suppose I have indices test_index* and want that field name 'name' is text and 'client number' is integer?

Regards

Hi,

I understand that it is a bit confusing as the name has not changed but the technical background has. I hope I can make it more comprehensible.
The obvious differences first:
When looking into a fairly recent version of Kibana, the menu entry Index Templates is now divided into Index Templates and Legacy Index Templates:

The API differs too as the legacy API endpoint is /_template while the new templates can be accessed by /_index_template.

So what is the difference between them?
While both types can be applied to indexes using a wildcard the way they are applied differs. Legacy index templates are merged together with higher priority overwriting settings from templates with lower priority. This worked well but had the potential to break things if a template is being changed having undesired affects to some indexes and it was hard to have an overview which index templates were applied.

The new templates solve that by adding an intermediate layer: Templates are not merged anymore - only the template with the highes priority is used. Instead, you can create reusable building blocks to solve reoccuring tasks which are included in each index template. This way, you do not have du duplicate settings or mappings to each template while still having a single point of truth which settings are applied.

Best regards
Wolfram

1 Like

Thank you.
So what would be the correct syntax for new, composite, template?
I wizzard is to... create name of the template :rofl:

I see example:

PUT _component_template/other_component_template
{
"template": {
"mappings": {
"properties": {
"ip_address": {
"type": "ip"
}
}
}
}
}

Where to place index pattern? I want apply this template for only some indices.

This depends largely on your usecase:
If you have no reusable blocks at all just go to Kibana Administration page, choose Index Management->Index templates and select Create Template (NOT `Create legacy template!). This will guide you trough the steps of creating the template.

If you might want to reuse settings or mappings you might want to break those into reusable building blocks first. With the Component templatesfeature in Kibana this is a guided process.

From doc examples:

PUT _component_template/other_component_template
{
  "template": {
    "mappings": {
      "properties": {
        "ip_address": {
          "type": "ip"
        }
      }
    }
  }
}

Where to place index pattern?

Why don't you use Kibana? It guides you through the creation.

You don't - component templates are not applied to indexes directly but are used in an index template. The index templates are then applied to an index pattern

OK, I think I got that. Composite template is a block of index template.
I.E. index template is a container with sometimes composite templates in.
Documentation is not clear at all.

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