Elasticsearch "Index templates index Templates"

Source: Internet
Author: User

Https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-templates.html

One

Index templates, define templates, automatically match when new indexes are created, and apply defined templates

New Index Template (Index templates)

We create a new index template template_1 set it to a primary shard of 1. Types are type1 and _source disabled

put /_template/template_1{   "template":  "t-*",   "Settings": {      "Number_of_shards":1  },   "mappings": {     "type1": {        "_source":{         "enabled": false       }    }  }}post /t-1get /t-1/_ mapping{    "T-1": {       "mappings": {           "Type1": {              "_source": {                 "Enabled": false             },             "Properties":  {}          }      }   }} 


Example: When we want to create an index again, we create an alias for it

PUT/_template/template_2{"template": "s-*", "settings": {"number_of_shards": 1}, "aliases": {"alias1": { }, "{Index}-alias": {}}}post/s-1get/s-1

When multiple index templates are created and an index is created and matched by multiple index templates, settings and mappings are merged into one configuration and applied to the index, which is controlled by the Order property of the index template. The order of the large will overwrite the previous configuration

put /_template/template_1{     "template": "*",     "order":0,      "Settings":{         "Number_of_shards":1     },     "Mappings":{         "type1": {              "_source":{                  "Enabled":false             }        }     }}PUT /_template/template_2{     "template": "tt-*",      "Order":1,     "Settings":{         " Number_of_shards ":1    },    " mappings ":{          "Type1": {             "_source":{                  "Enabled":true             }        }     }}POST /tt-1            =>   will be matched by both of the above templates, and for the _source attribute  order=1 will overwrite order=0  that is  enabled:true


File configuration: We can add the JSON configuration file in the Config/templates directory again


Elasticsearch "Index templates index Templates"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.