1,首先看一下下面这个索引模板
curl -XPUT "master:9200/_template/template_1?pretty" -H 'Content-Type: application/json' -d' ---> 模板名字叫做template1
{
"template" : "hello*", -------------> 匹配的索引名字
"order" : 0, -------------> 代表权重,如果有多个模板的时候,优先进行匹配,值越大,权重越高
"settings" : {
"number_of_shards" : 1 -------> 主分片的设置
},
"aliases": {
"alias_1" : {} ------> 索引对应的别名
},
"mappings" : { -----> 字段的映射
"_default_": { -----------------> 默认的配置
"_source" : { "enabled" : false }, ------> 字段原始的具体值是否要存
"_all": { "enabled": false }, -----> 禁用_all 字段,
"dynamic": "strict" ----------> 只可以用定义的字段,关闭默认的自动推断数据类型
},
"type1" : { ----> 类型名字
"_source" : { "enabled" : true }, ------> 字段具体的值是否要存
"properties": { ---------> 字段映射
"@timestamp": { -------> 具体的字段映射
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"doc_values": true,
"index": "not_analyzed",
"type": "string"
},
"Guid": {
"doc_values": true,
"index": "not_analyzed",
"type": "string"
},
"LogLevel": {
"type": "long"
}
}
}
}
}
'curl -XPUT "master:9200/_temp