index template

本文详细介绍了Elasticsearch的Index Template,包括其作用、如何定义、如何处理多个匹配的Template、如何查询和检查Template的存在,以及如何删除Template。通过示例展示了如何设置order以控制合并顺序,并提醒了order相同的Template可能导致的不确定性问题。
摘要由CSDN通过智能技术生成

index template

作用

Index template 在创建新 index 时可以自动应用的 settings 和 mappings。 Elasticsearch 根据与 index 名称匹配的 index 模式将模板应用于新索引。

Index template 仅在 index 创建期间应用。 对 index template 的更改不会影响现有索引。 create index API 请求中指定的设置和映射会覆盖索引模板中指定的任何设置或映射。

定义一个template

PUT /_template/<index-template>

例如

PUT _template/logs_template
{
  "index_patterns": "logs-*",
  "order": 1, 
  "settings": {
    "number_of_shards": 4,
    "number_of_replicas": 1
  },
  "mappings": { 
    "properties": {
      "@timestamp": {
        "type": "date"
      }
    }
  }
}

定义了一个叫做 logs_template 的 index template。它的 index_patterns 定义为 “logs-*”,说明,任何以 “logs-” 为开头 index 将具有在该 template 里定义的 settings 及 mappings 属性。“order” :如果索引与多个模板匹配&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值