Elasticsearch template configuration

本文深入探讨了Elasticsearch中索引模板的定义与应用,包括如何在运行时通过API设置、映射等进行索引管理,以及模板在配置文件中的部署方式。同时,阐述了在调整索引模板时遇到的挑战及解决方案,如在运行时修改模板、重新索引或直接替换旧模板的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值