https://people.mozilla.org/~wkahngreene/elastic/guide/reference/api/admin-indices-templates.html
—- layout: guide title: Index Templates API cat: guide sidebar: reference_api —-
Index templates allow to define templates that will automatically be applied to new indices created. The templates include both settings and mappings, and a simple pattern template that controls if the template will be applied to the index created. For example:
Defines a template named template_1, with a template pattern of te*. The settings and mappings will be applied to any index name that matches thete* template.
Deleting a Template
Index templates are identified by a name (in the above case template_1) and can be delete as well:
GETting a Template
Index templates are identified by a name (in the above case template_1) and can be retrieved using the following:
To get list of all index templates you can use Cluster State API and check for the metadata/templates section of the response.
Multiple Template Matching
Multiple index templates can potentially match an index, in this case, both the settings and mappings are merged into the final configuration of the index. The order of the merging can be controlled using the order parameter, with lower order being applied first, and higher orders overriding them. For example:
The above will disable storing the _source on all type1 types, but for indices of that start with te*, source will still be enabled. Note, for mappings, the merging is “deep”, meaning that specific object/property based mappings can easily be added/overridden on higher order templates, with lower order templates providing the basis.
本文介绍Elasticsearch中索引模板的使用方法,包括定义、应用、删除及获取模板等操作。通过设置模板模式、索引配置及映射规则,实现新建索引时的自动化配置。
2574

被折叠的 条评论
为什么被折叠?



