A component template is a reusable block of Elasticsearch configuration. It becomes useful when a composable index template attaches it to one or more index patterns, allowing shared settings or mappings to be maintained once and reused across indexes. section 6.6 section 6.6.2
Share development settings and mappings
Create separate components for an environment’s settings and mapping schema, then compose them into a cars template: POST _component_template/dev_settings_component_template { "template": { "settings": { "number_of_shards": 3, "number_of_replicas": 3 } } } POST _component_template/dev_mapping_component_template { "template": { "mappings": { "properties": { "created_by": { "type": "text" }, "version": { "type": "float" } } } } } POST _index_template/composed_cars_template { "index_patterns": ["*cars*"], "priority": 200, "composed_of": [ "dev_settings_component_template", "dev_mapping_component_template" ] } The component requests define reusable configuration but no index pattern. The index template supplies the pattern and combines both components; indexes such as vintage_cars or cars_sold_in_feb then receive the resulting settings and mappings. section 6.6.2
Keep these operational rules in mind:
- Associate a component template with an index template before relying on it; by itself, it has no index pattern and is not useful for index creation. section 6.6 section 6.6.2
- Reuse one component across multiple composable index templates, such as sharing development settings among several index families. section 6.6
- Resolve overlaps carefully: higher-priority matching index templates take precedence, while explicitly supplied index settings take precedence over template configuration. section 6.6 section 6.6.1
Use the composition diagram to see how several index templates can share component templates while a standalone index template remains independent. section 6.6
