In Elasticsearch, index templates can be composed by defining multiple templates with different priorities. The system merges these templates by applying the settings from lower priority templates first, then overriding them with higher priority templates. For example, a base template with priority 10 sets number_of_shards to 1. A child template with priority 20 sets number_of_shards to 3. When merged, the final setting is 3 because the child template has higher priority. If two templates have the same priority, the last loaded template's settings override earlier ones. This priority and composition system allows flexible and layered index template management.