Index templates allow defining templates thatwill automatically be applied to new indices created. The templates may include(1) settings, (2) mappings, or (3) a simple index pattern template thatcontrols if the template will be applied to the index created.
The templates could be placed in the runtimeusing APIs, such as putSettings, putMappings, etc. But this approach is NOTrecommended. Since templates could not be overwritten if there is a conflictwith the old one. In other words, once you have defined a template for certainindices that are being used, it is highly possible your new template does notwork for those indices. In order to adjust a template in the runtime,especially when changing the mappings, you have 2 options:
1. in place modification(notice: old data may not be affected)
a. stop the node
b. delete the old settings/mappings
c. put new settings/mappings
d. restart the node.
2. reindex everything
a. create a new indexwith the new template
b. copy the old data tothe new index during off-peak time
c. redirect requests tothe new one when the clone is done.
d. delete the old index
Index templates can also be placed within theconfig location (path.conf) under the templates directory (note, make sure toplace them on all master eligible nodes). All templates will be addedautomatically if it matches an index at the very beginning. This is recommendedapproach. Note, all templates are written in json format.
References
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-source-field.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-all-field.html
本文深入探讨了Elasticsearch中索引模板的定义与应用,包括如何在运行时通过API设置、映射等进行索引管理,以及模板在配置文件中的部署方式。同时,阐述了在调整索引模板时遇到的挑战及解决方案,如在运行时修改模板、重新索引或直接替换旧模板的方法。
3326

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



