Component template APIedit

Component templates are building blocks that specify mappings, settings, or alias configuration, but don’t apply to a set of indices themselves. To be used a component template must be specified in the composed_of of an index template.

PUT _component_template/template_1
  "template": {
    "settings": {
      "number_of_shards": 1
    "mappings": {
      "_source": {
        "enabled": false
      "properties": {
        "host_name": {
          "type": "keyword"
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z yyyy"


PUT /_component_template/<component-template>


Use the PUT component template API to create or update a component template.

Component templates define settings, mappings, and aliases that you can automatically apply when creating new indices. On their own component templates are not matched or applied to an index, instead they are used in the composed_of definition of an index template to make up the final index configuration.

Component templates are only used during index creation. Changes to component templates do not affect existing indices. Settings and mappings specified in create index API requests and index templates override any settings or mappings specified in a component template.

Comments in component templatesedit

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.

Getting component templatesedit