简介:
模板分为:索引模板、多组件模板(优先级高)
1.创建索引索引模板示例:
语法为:
PUT /_template/模板名称
{
"index_patterns":["正则,匹配该模板应用的索引"],
"order":"数值,模板优先级",
"settings":{
"settinngs相关配置"
},
"mappings":{
"mappings相关配置"
}
}
PUT _template/template_1
{"index_patterns": ["te*", "bar*"],"settings": {"number_of_shards": 1},"mappings": {"_source": {"enabled": false},"properties": {"host_name": {"type": "keyword"},"created_at": {"type": "date","format": "EEE MMM dd HH:mm:ss Z yyyy"}}}
}
创建请求: PUT /_template/<index-template>
请求参数:<index-template> ---* string 要创建的索引模板的名称
请求正文参数:
index_patterns---* string 匹配索引名称的通配符表达式
aliases--- 索引别名
mappings---映射索引中的字段
settings--索引的配置选项
version ---int 从外部管理索引模板的版本号