ES中mapping设置的一些说明,如下:
curl ${es_host}:9200/_template/prefix-estype -d
'{
"order": 0,
"template": "prefix-*-estype-*",
"settings": {
"index": {
"number_of_shards": "5", #设置分片数
"number_of_replicas": "1" #设置副本数
}
},
"mappings": {
"estype": {
"dynamic": true, #控制字段的新增(true:(默认)允许自动新增字段;false:不允许自动新增字段,文档可以正常写入,但无法对新增字段进行查询等操作;strict:文档不能写入,报错)
"dynamic_templates": [
{
"string_as_keyword": {
"match_mapping_type": "string", #可以改变ES的想法,本来ES觉得这个字段应该映射成string,可以修改成keyword
"match": "*", #主要是对字段名称进行匹配处理
"mapping": {
"index": "not_analyzed", #设置为该值可以保证该字段能通过检索查询到
"type": "keyword" #上面定义的类型修改成keyword
}
}
}
],
"properties": {
"timestamp": {
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS||epoch_millis",
"type": "date",
"store": true
},
"interval": {
"type": "long",
"store": true
},
"url": {
"type": "keyword",
"store": true
},
"resp": {
"search_analyzer": "ik_max_word",
"analyzer": "ik_max_word",
"type": "text",
"store": true
},
"params": {
"search_analyzer": "ik_max_word",
"analyzer": "ik_max_word",
"type": "text"
}
}
}
},
"aliases": {}
}'