项目中需要支持索引插入新字段,字段可以进行查询和聚合,测试时发现默认的索引字段是做聚合的。
在ES的官方文档中找到dynamic-templates功能,可以增加默认索引类型
地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html
kibana测试URL:
GET maptest/_search
{
"query": {
"match_all": {}
}
}
DELETE maptest
PUT maptest
PUT maptest/_mapping/test
{
"properties": {
"appid":{
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"uid":{
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"sid":{
"type": "string",
"store": "yes",
"index": "not_analyzed"
}
}
}
PUT ma