"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” : {