Elasticsearch之Template详解_elasticsearchtemplate(1)

      "allocation" : {
        "include" : {
          "\_tier\_preference" : "data\_content"
        }
      }
    },
    "number\_of\_shards" : "1",
    "provided\_name" : "template\_index",
    "creation\_date" : "1640524317827",
    "number\_of\_replicas" : "1",
    "uuid" : "e5zbL0\_lQUyYWFkDqmx5xw",
    "version" : {
      "created" : "7160099"
    }
  }
}

}
}


可以看到索引已经按照我们设定的默认模板,来自动生成了分片的配置。


### 示例2


再创建一个模板,匹配规则为:索引的名称以template开头的,设定分片数量为1,副本数量为3。  
 `date_detection`:mapping设置,如果字符串符合日期的类型,就自动匹配为日期,true为开启,false为关闭  
 `numeric_detection`:mapping设置,如果字符串是数字的话,自动映射数字类型。



put _template/template_test
{
“index_patterns”:[“template*”],
“order”:1,
“settings”:{
“number_of_shards”:1,
“number_of_replicas”:3
},
“mappings”:{
“date_detection”:false,
“numeric_detection”:true
}
}


我们创建一个匹配通配规则的索引,获取信息。可以看到如下,匹配到了`template_test`,因为`template_default`的order为0,所以以`template_test`的分片副本设置为准。



put template_index2

get template_index2

{
“template_index2” : {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值