ES 动态模版配置:
curl -XDELETE http://127.0.0.1:9200/_template/${template-name} //删除模板
curl -GET http://127.0.0.1:9200/_template/${template-name} //获取模版
curl -XGET http://127.0.0.1:9200/_cat/indices/${index-name-prefix*} //获取索引
curl -XDELETE http://127.0.0.1:9200/${index-name}?pretty //删除索引
//创建模板
curl -XPUT http://127.0.0.1:9200/_template/${template-name} -d ' //设置模版名字
{
"template": "${index-template-prefix*}", //设置模版自建索引匹配前缀
"order": 0, //设置模板优先级,同属性高优先级覆盖低优先级
"settings": {
"number_of_replicas": 1, //副本数
"number_of_shards": 10 //主分片数
},
"mappings": {
"event": {
"date_detection": false, //关闭日期推断检测
"_all": {
"enabled": false //禁用该字段,不支持无字段文档检索
},
"properties": {
"id": {
"type": "keyword"
},
"uid": {
"type": "keyword",
"doc_values": false //不分词字眼若不排序和聚合仅做过滤和匹配用可禁用该属性
},
"event": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"time_stamp": {
"type": "date",
"ignore_malformed": true, //忽略非正常时间戳数字
"format": "epoch_millis" //时间戳格式
},
"dev": {
"type": "keyword"
},
"extra": {
"type": "text" //分词字段
}
},
"dynamic_templates": [{
"string_as_keyword": {
"match": "*", //非指定字段统配
"match_mapping_type": "string", //匹配json中的格式
"mapping": {
"type": "keyword",
"doc_values": false, // 非指定字段禁用该属性,仅做过滤和匹配用
"ignore_above": 256 //超长字段部分部略
}
}
}]
}
}
}'