调用以下语句后,ES在插入时指定aipplog*的代码时,如果索引不存在会自动套用模版内的索引,实现ES模版化套用
ES官网相关介绍:https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html
curl -XPUT 'localhost:9200/_template/template_aipp?pretty' -d '{
"template": "aipplog*",
"order": 1,
"settings": {
"number_of_shards": 1
},
"mappings": {
"log": {
"dynamic_templates": [
{
"param_template": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
}
}
}
],
"properties": {
"svc": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"csid": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"busid": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"appid": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"uid": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"event": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"sid": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"ret": {
"type": "string",
"store": "yes",
"index": "no"
},
"call_time": {
"type": "date",
"store": "yes",
"format": "YY/MM/dd-HH:mm:ss SSSZ"
},
"type": {
"type": "string",
"store": "yes",
"index": "no"
},
"input_text": {
"type": "string",
"store": "yes",
"index": "analyzed",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"result": {
"type": "string",
"store": "yes",
"index": "analyzed",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"data": {
"type": "string",
"store": "yes",
"index": "no"
},
"data_content": {
"type": "string",
"store": "yes",
"index": "no"
},
"data_list": {
"type": "nested",
"properties": {
"data": {
"type": "string",
"store": "yes",
"index": "no"
},
"data_content": {
"type": "string",
"store": "yes",
"index": "no"
}
}
},
"where": {
"type": "string",
"store": "yes",
"index": "analyzed",
"analyzer": "standard",
"search_analyzer": "standard"
},
"aue": {
"type": "string",
"store": "yes",
"index": "no"
},
"auf": {
"type": "string",
"store": "yes",
"index": "no"
}
}
}
}
}'
echo "the index template of aipplog* is created"