@@ -332,7 +332,7 @@ This is the template to be applied, may optionally include a `mappings`,
332
332
`composed_of`::
333
333
(Optional, array of strings)
334
334
An ordered list of component template names. Component templates are merged in the order
335
- specified, meaning that the last component template specified has the highest precedence. See
335
+ specified, meaning that the last component template specified has the highest precedence. See
336
336
<<multiple-component-templates,Composing multiple component templates>> for an example.
337
337
338
338
`priority`::
@@ -507,13 +507,15 @@ PUT /_index_template/template_1
507
507
--------------------------------------------------
508
508
509
509
[[multiple-component-templates]]
510
- ===== Composing multiple component templates
510
+ ===== Composing aliases, mappings, and settings
511
511
512
512
When multiple component templates are specified in the `composed_of` field for an index template,
513
513
they are merged in the order specified, meaning that later component templates override earlier
514
- component templates.
514
+ component templates. Any mappings, settings, or aliases from the parent index template are merged
515
+ in next. Finally, any configuration on the index request itself is merged.
515
516
516
- For two component templates, the order they are specified changes the number of shards for an index:
517
+ In this example, the order of the two component templates changes the number of shards for an
518
+ index:
517
519
518
520
[source,console]
519
521
--------------------------------------------------
@@ -545,6 +547,16 @@ PUT /_index_template/template_1
545
547
In this case, an index matching `t*` will have three primary shards. If the order of composed
546
548
templates were reversed, the index would have two primary shards.
547
549
550
+ Mapping definitions are merged recursively, which means that later mapping components can
551
+ introduce new field mappings and update the mapping configuration. If a field mapping is
552
+ already contained in an earlier component, its definition will be completely overwritten
553
+ by the later one.
554
+
555
+ This recursive merging strategy applies not only to field mappings, but also root options like
556
+ `dynamic_templates` and `meta`. If an earlier component contains a `dynamic_templates` block,
557
+ then by default new `dynamic_templates` entries are appended onto the end. If an entry already
558
+ exists with the same key, then it is overwritten by the new definition.
559
+
548
560
[[indices-get-template]]
549
561
=== Get index template API [[getting-templates]]
550
562
++++
@@ -601,4 +613,4 @@ GET /_index_template/temp*
601
613
[source,console]
602
614
--------------------------------------------------
603
615
GET /_index_template
604
- --------------------------------------------------
616
+ --------------------------------------------------
0 commit comments