創建模板:
PUT _template/metric_datatest
{
"index_patterns": ["metric_datatest-*"],
"order": 0,
"settings": {
"analysis": {
"analyzer": {
"tags_analyzer": {
"type": "pattern",
"pattern": ","
}
}
}
},
"mappings": {
"properties": {
"ts": {
"type": "long"
},
"name": {
"type": "keyword"
},
"tags": {
"type": "text",
"analyzer": "tags_analyzer"
},
"count": {
"type": "long"
},
"sum": {
"type": "double"
},
"max": {
"type": "double"
},
"min": {
"type": "double"
}
}
},
"aliases": {
"metric_datatest": {}
}
}
使用模板創建索引,不用指定mappings和settings:
PUT /metric_datatest-2021-04-16
插入需要指定具體的索引名,查詢時只要使用別名metric_datatest就可以,可以並發查詢別名對應的所有索引。
不使用模板創建索引
PUT /metric_data
{
"settings": {
"analysis": {
"analyzer": {
"tags_analyzer": {
"type": "pattern",
"pattern": ","
}
}
}
},
"mappings": {
"properties": {
"ts": {
"type": "long"
},
"name": {
"type": "keyword"
},
"tags": {
"type": "text",
"analyzer": "tags_analyzer"
},
"count": {
"type": "long"
},
"sum": {
"type": "double"
},
"max": {
"type": "double"
},
"min": {
"type": "double"
}
}
}
}
