Create or update a component template Added in 7.8.0
Creates or updates a component template. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases.
An index template can be composed of multiple component templates.
To use a component template, specify it in an index template’s composed_of
list.
Component templates are only applied to new data streams and indices as part of a matching index template.
Settings and mappings specified directly in the index template or the create index request override any settings or mappings specified in a component template.
Component templates are only used during index creation. For data streams, this includes data stream creation and the creation of a stream’s backing indices. Changes to component templates do not affect existing indices, including a stream’s backing indices.
You can use C-style /* *\/
block comments in component templates.
You can include comments anywhere in the request body except before the opening curly bracket.
Path parameters
-
Name of the component template to create. Elasticsearch includes the following built-in component templates:
logs-mappings
;logs-settings
;metrics-mappings
;metrics-settings
;synthetics-mapping
;synthetics-settings
. Elastic Agent uses these templates to configure backing indices for its data streams. If you use Elastic Agent and want to overwrite one of these templates, set theversion
for your replacement template higher than the current version. If you don’t use Elastic Agent and want to disable all built-in component and index templates, setstack.templates.enabled
tofalse
using the cluster update settings API.
Query parameters
-
create boolean
If
true
, this request cannot replace or update existing component templates. -
master_timeout string
Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
Body Required
-
Additional properties are allowed.
-
version number
-
_meta object
-
deprecated boolean
Marks this index template as deprecated. When creating or updating a non-deprecated index template that uses deprecated components, Elasticsearch will emit a deprecation warning.
curl \
-X PUT http://api.example.com/_component_template/{name} \
-H "Content-Type: application/json" \
-d '{"template":{"aliases":{"additionalProperty1":{"filter":{},"index_routing":"string","is_hidden":true,"is_write_index":true,"routing":"string","search_routing":"string"},"additionalProperty2":{"filter":{},"index_routing":"string","is_hidden":true,"is_write_index":true,"routing":"string","search_routing":"string"}},"mappings":{"all_field":{"analyzer":"string","enabled":true,"omit_norms":true,"search_analyzer":"string","similarity":"string","store":true,"store_term_vector_offsets":true,"store_term_vector_payloads":true,"store_term_vector_positions":true,"store_term_vectors":true},"date_detection":true,"dynamic":"strict","dynamic_date_formats":["string"],"dynamic_templates":[{}],"_field_names":{"enabled":true},"index_field":{"enabled":true},"_meta":{"additionalProperty1":{},"additionalProperty2":{}},"numeric_detection":true,"properties":{},"_routing":{"required":true},"_size":{"enabled":true},"_source":{"compress":true,"compress_threshold":"string","enabled":true,"excludes":["string"],"includes":["string"],"mode":"disabled"},"runtime":{"additionalProperty1":{"fields":{"additionalProperty1":{"type":"boolean"},"additionalProperty2":{"type":"boolean"}},"fetch_fields":[{"field":"string","format":"string"}],"format":"string","input_field":"string","target_field":"string","target_index":"string","script":{"source":"string","id":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"":"painless","options":{"additionalProperty1":"string","additionalProperty2":"string"}},"type":"boolean"},"additionalProperty2":{"fields":{"additionalProperty1":{"type":"boolean"},"additionalProperty2":{"type":"boolean"}},"fetch_fields":[{"field":"string","format":"string"}],"format":"string","input_field":"string","target_field":"string","target_index":"string","script":{"source":"string","id":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"":"painless","options":{"additionalProperty1":"string","additionalProperty2":"string"}},"type":"boolean"}},"enabled":true,"subobjects":true,"_data_stream_timestamp":{"enabled":true}},"settings":{"index":{},"mode":"string","routing_path":"string","soft_deletes":{"enabled":true,"retention_lease":{"period":"string"}},"sort":{"field":"string","order":"asc","mode":"min","missing":"_last"},"number_of_shards":42.0,"number_of_replicas":42.0,"number_of_routing_shards":42.0,"check_on_startup":"true","codec":"string","":"string","load_fixed_bitset_filters_eagerly":true,"hidden":true,"auto_expand_replicas":"string","merge":{"scheduler":{"":42.0}},"search":{"idle":{"after":"string"},"slowlog":{"level":"string","source":42.0,"reformat":true,"threshold":{"query":{"warn":"string","info":"string","debug":"string","trace":"string"},"fetch":{"warn":"string","info":"string","debug":"string","trace":"string"}}}},"refresh_interval":"string","max_result_window":42.0,"max_inner_result_window":42.0,"max_rescore_window":42.0,"max_docvalue_fields_search":42.0,"max_script_fields":42.0,"max_ngram_diff":42.0,"max_shingle_diff":42.0,"blocks":{"":true},"max_refresh_listeners":42.0,"analyze":{"":42.0},"highlight":{"max_analyzed_offset":42.0},"max_terms_count":42.0,"max_regex_length":42.0,"routing":{"allocation":{"enable":"all","include":{"_tier_preference":"string","_id":"string"},"initial_recovery":{"_id":"string"},"disk":{"threshold_enabled":true}},"rebalance":{"enable":"all"}},"gc_deletes":"string","default_pipeline":"string","final_pipeline":"string","lifecycle":{"name":"string","":true,"origination_date":42.0,"parse_origination_date":true,"step":{"wait_time_threshold":"string"},"rollover_alias":"string"},"provided_name":"string","uuid":"string","version":{"created":"string","created_string":"string"},"verified_before_close":true,"format":"string","max_slices_per_scroll":42.0,"translog":{"sync_interval":"string","durability":"request","":42.0,"retention":{"":42.0,"age":"string"}},"query_string":{"":true},"priority":42.0,"top_metrics_max_size":42.0,"analysis":{"analyzer":{},"char_filter":{},"filter":{},"normalizer":{},"tokenizer":{}},"settings":{},"time_series":{"":"string"},"queries":{"cache":{"enabled":true}},"similarity":{},"mapping":{"coerce":true,"total_fields":{"limit":42.0,"ignore_dynamic_beyond_limit":true},"depth":{"limit":42.0},"nested_fields":{"limit":42.0},"nested_objects":{"limit":42.0},"field_name_length":{"limit":42.0},"dimension_fields":{"limit":42.0},"ignore_malformed":true},"indexing.slowlog":{"level":"string","source":42.0,"reformat":true,"threshold":{"index":{"warn":"string","info":"string","debug":"string","trace":"string"}}},"indexing_pressure":{"memory":{"limit":42.0}},"store":{"":"fs","allow_mmap":true}},"defaults":{"index":{},"mode":"string","routing_path":"string","soft_deletes":{"enabled":true,"retention_lease":{"period":"string"}},"sort":{"field":"string","order":"asc","mode":"min","missing":"_last"},"number_of_shards":42.0,"number_of_replicas":42.0,"number_of_routing_shards":42.0,"check_on_startup":"true","codec":"string","":"string","load_fixed_bitset_filters_eagerly":true,"hidden":true,"auto_expand_replicas":"string","merge":{"scheduler":{"":42.0}},"search":{"idle":{"after":"string"},"slowlog":{"level":"string","source":42.0,"reformat":true,"threshold":{"query":{"warn":"string","info":"string","debug":"string","trace":"string"},"fetch":{"warn":"string","info":"string","debug":"string","trace":"string"}}}},"refresh_interval":"string","max_result_window":42.0,"max_inner_result_window":42.0,"max_rescore_window":42.0,"max_docvalue_fields_search":42.0,"max_script_fields":42.0,"max_ngram_diff":42.0,"max_shingle_diff":42.0,"blocks":{"":true},"max_refresh_listeners":42.0,"analyze":{"":42.0},"highlight":{"max_analyzed_offset":42.0},"max_terms_count":42.0,"max_regex_length":42.0,"routing":{"allocation":{"enable":"all","include":{"_tier_preference":"string","_id":"string"},"initial_recovery":{"_id":"string"},"disk":{"threshold_enabled":true}},"rebalance":{"enable":"all"}},"gc_deletes":"string","default_pipeline":"string","final_pipeline":"string","lifecycle":{"name":"string","":true,"origination_date":42.0,"parse_origination_date":true,"step":{"wait_time_threshold":"string"},"rollover_alias":"string"},"provided_name":"string","uuid":"string","version":{"created":"string","created_string":"string"},"verified_before_close":true,"format":"string","max_slices_per_scroll":42.0,"translog":{"sync_interval":"string","durability":"request","":42.0,"retention":{"":42.0,"age":"string"}},"query_string":{"":true},"priority":42.0,"top_metrics_max_size":42.0,"analysis":{"analyzer":{},"char_filter":{},"filter":{},"normalizer":{},"tokenizer":{}},"settings":{},"time_series":{"":"string"},"queries":{"cache":{"enabled":true}},"similarity":{},"mapping":{"coerce":true,"total_fields":{"limit":42.0,"ignore_dynamic_beyond_limit":true},"depth":{"limit":42.0},"nested_fields":{"limit":42.0},"nested_objects":{"limit":42.0},"field_name_length":{"limit":42.0},"dimension_fields":{"limit":42.0},"ignore_malformed":true},"indexing.slowlog":{"level":"string","source":42.0,"reformat":true,"threshold":{"index":{"warn":"string","info":"string","debug":"string","trace":"string"}}},"indexing_pressure":{"memory":{"limit":42.0}},"store":{"":"fs","allow_mmap":true}},"data_stream":"string","lifecycle":{"data_retention":"string","downsampling":{"rounds":[{"after":"string","config":{"fixed_interval":"string"}}]},"enabled":true}},"version":42.0,"_meta":{"additionalProperty1":{},"additionalProperty2":{}},"deprecated":true}'
{
"template": {
"aliases": {
"additionalProperty1": {
"filter": {},
"index_routing": "string",
"is_hidden": true,
"is_write_index": true,
"routing": "string",
"search_routing": "string"
},
"additionalProperty2": {
"filter": {},
"index_routing": "string",
"is_hidden": true,
"is_write_index": true,
"routing": "string",
"search_routing": "string"
}
},
"mappings": {
"all_field": {
"analyzer": "string",
"enabled": true,
"omit_norms": true,
"search_analyzer": "string",
"similarity": "string",
"store": true,
"store_term_vector_offsets": true,
"store_term_vector_payloads": true,
"store_term_vector_positions": true,
"store_term_vectors": true
},
"date_detection": true,
"dynamic": "strict",
"dynamic_date_formats": [
"string"
],
"dynamic_templates": [
{}
],
"_field_names": {
"enabled": true
},
"index_field": {
"enabled": true
},
"_meta": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"numeric_detection": true,
"properties": {},
"_routing": {
"required": true
},
"_size": {
"enabled": true
},
"_source": {
"compress": true,
"compress_threshold": "string",
"enabled": true,
"excludes": [
"string"
],
"includes": [
"string"
],
"mode": "disabled"
},
"runtime": {
"additionalProperty1": {
"fields": {
"additionalProperty1": {
"type": "boolean"
},
"additionalProperty2": {
"type": "boolean"
}
},
"fetch_fields": [
{
"field": "string",
"format": "string"
}
],
"format": "string",
"input_field": "string",
"target_field": "string",
"target_index": "string",
"script": {
"source": "string",
"id": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"": "painless",
"options": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
},
"type": "boolean"
},
"additionalProperty2": {
"fields": {
"additionalProperty1": {
"type": "boolean"
},
"additionalProperty2": {
"type": "boolean"
}
},
"fetch_fields": [
{
"field": "string",
"format": "string"
}
],
"format": "string",
"input_field": "string",
"target_field": "string",
"target_index": "string",
"script": {
"source": "string",
"id": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"": "painless",
"options": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
},
"type": "boolean"
}
},
"enabled": true,
"subobjects": true,
"_data_stream_timestamp": {
"enabled": true
}
},
"settings": {
"index": {},
"mode": "string",
"routing_path": "string",
"soft_deletes": {
"enabled": true,
"retention_lease": {
"period": "string"
}
},
"sort": {
"field": "string",
"order": "asc",
"mode": "min",
"missing": "_last"
},
"number_of_shards": 42.0,
"number_of_replicas": 42.0,
"number_of_routing_shards": 42.0,
"check_on_startup": "true",
"codec": "string",
"": "string",
"load_fixed_bitset_filters_eagerly": true,
"hidden": true,
"auto_expand_replicas": "string",
"merge": {
"scheduler": {
"": 42.0
}
},
"search": {
"idle": {
"after": "string"
},
"slowlog": {
"level": "string",
"source": 42.0,
"reformat": true,
"threshold": {
"query": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
},
"fetch": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
}
}
}
},
"refresh_interval": "string",
"max_result_window": 42.0,
"max_inner_result_window": 42.0,
"max_rescore_window": 42.0,
"max_docvalue_fields_search": 42.0,
"max_script_fields": 42.0,
"max_ngram_diff": 42.0,
"max_shingle_diff": 42.0,
"blocks": {
"": true
},
"max_refresh_listeners": 42.0,
"analyze": {
"": 42.0
},
"highlight": {
"max_analyzed_offset": 42.0
},
"max_terms_count": 42.0,
"max_regex_length": 42.0,
"routing": {
"allocation": {
"enable": "all",
"include": {
"_tier_preference": "string",
"_id": "string"
},
"initial_recovery": {
"_id": "string"
},
"disk": {
"threshold_enabled": true
}
},
"rebalance": {
"enable": "all"
}
},
"gc_deletes": "string",
"default_pipeline": "string",
"final_pipeline": "string",
"lifecycle": {
"name": "string",
"": true,
"origination_date": 42.0,
"parse_origination_date": true,
"step": {
"wait_time_threshold": "string"
},
"rollover_alias": "string"
},
"provided_name": "string",
"uuid": "string",
"version": {
"created": "string",
"created_string": "string"
},
"verified_before_close": true,
"format": "string",
"max_slices_per_scroll": 42.0,
"translog": {
"sync_interval": "string",
"durability": "request",
"": 42.0,
"retention": {
"": 42.0,
"age": "string"
}
},
"query_string": {
"": true
},
"priority": 42.0,
"top_metrics_max_size": 42.0,
"analysis": {
"analyzer": {},
"char_filter": {},
"filter": {},
"normalizer": {},
"tokenizer": {}
},
"settings": {},
"time_series": {
"": "string"
},
"queries": {
"cache": {
"enabled": true
}
},
"similarity": {},
"mapping": {
"coerce": true,
"total_fields": {
"limit": 42.0,
"ignore_dynamic_beyond_limit": true
},
"depth": {
"limit": 42.0
},
"nested_fields": {
"limit": 42.0
},
"nested_objects": {
"limit": 42.0
},
"field_name_length": {
"limit": 42.0
},
"dimension_fields": {
"limit": 42.0
},
"ignore_malformed": true
},
"indexing.slowlog": {
"level": "string",
"source": 42.0,
"reformat": true,
"threshold": {
"index": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
}
}
},
"indexing_pressure": {
"memory": {
"limit": 42.0
}
},
"store": {
"": "fs",
"allow_mmap": true
}
},
"defaults": {
"index": {},
"mode": "string",
"routing_path": "string",
"soft_deletes": {
"enabled": true,
"retention_lease": {
"period": "string"
}
},
"sort": {
"field": "string",
"order": "asc",
"mode": "min",
"missing": "_last"
},
"number_of_shards": 42.0,
"number_of_replicas": 42.0,
"number_of_routing_shards": 42.0,
"check_on_startup": "true",
"codec": "string",
"": "string",
"load_fixed_bitset_filters_eagerly": true,
"hidden": true,
"auto_expand_replicas": "string",
"merge": {
"scheduler": {
"": 42.0
}
},
"search": {
"idle": {
"after": "string"
},
"slowlog": {
"level": "string",
"source": 42.0,
"reformat": true,
"threshold": {
"query": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
},
"fetch": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
}
}
}
},
"refresh_interval": "string",
"max_result_window": 42.0,
"max_inner_result_window": 42.0,
"max_rescore_window": 42.0,
"max_docvalue_fields_search": 42.0,
"max_script_fields": 42.0,
"max_ngram_diff": 42.0,
"max_shingle_diff": 42.0,
"blocks": {
"": true
},
"max_refresh_listeners": 42.0,
"analyze": {
"": 42.0
},
"highlight": {
"max_analyzed_offset": 42.0
},
"max_terms_count": 42.0,
"max_regex_length": 42.0,
"routing": {
"allocation": {
"enable": "all",
"include": {
"_tier_preference": "string",
"_id": "string"
},
"initial_recovery": {
"_id": "string"
},
"disk": {
"threshold_enabled": true
}
},
"rebalance": {
"enable": "all"
}
},
"gc_deletes": "string",
"default_pipeline": "string",
"final_pipeline": "string",
"lifecycle": {
"name": "string",
"": true,
"origination_date": 42.0,
"parse_origination_date": true,
"step": {
"wait_time_threshold": "string"
},
"rollover_alias": "string"
},
"provided_name": "string",
"uuid": "string",
"version": {
"created": "string",
"created_string": "string"
},
"verified_before_close": true,
"format": "string",
"max_slices_per_scroll": 42.0,
"translog": {
"sync_interval": "string",
"durability": "request",
"": 42.0,
"retention": {
"": 42.0,
"age": "string"
}
},
"query_string": {
"": true
},
"priority": 42.0,
"top_metrics_max_size": 42.0,
"analysis": {
"analyzer": {},
"char_filter": {},
"filter": {},
"normalizer": {},
"tokenizer": {}
},
"settings": {},
"time_series": {
"": "string"
},
"queries": {
"cache": {
"enabled": true
}
},
"similarity": {},
"mapping": {
"coerce": true,
"total_fields": {
"limit": 42.0,
"ignore_dynamic_beyond_limit": true
},
"depth": {
"limit": 42.0
},
"nested_fields": {
"limit": 42.0
},
"nested_objects": {
"limit": 42.0
},
"field_name_length": {
"limit": 42.0
},
"dimension_fields": {
"limit": 42.0
},
"ignore_malformed": true
},
"indexing.slowlog": {
"level": "string",
"source": 42.0,
"reformat": true,
"threshold": {
"index": {
"warn": "string",
"info": "string",
"debug": "string",
"trace": "string"
}
}
},
"indexing_pressure": {
"memory": {
"limit": 42.0
}
},
"store": {
"": "fs",
"allow_mmap": true
}
},
"data_stream": "string",
"lifecycle": {
"data_retention": "string",
"downsampling": {
"rounds": [
{
"after": "string",
"config": {
"fixed_interval": "string"
}
}
]
},
"enabled": true
}
},
"version": 42.0,
"_meta": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"deprecated": true
}
{
"acknowledged": true
}