elasticsearch动态模板
问题描述:
我怎么下面elasticsearch动态模板
"ipAddress" : {
"properties" : {
"bytes" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
我试图像多个选项,但不能松了如何将文本/字符串字段更改为IP数据类型的映射设置动态模板。我猜测这是由于嵌套,但我是新来的动态模板,不知道如何构建一个
curl -XPUT localhost:9200/_template/clee-new-* -d '{
"template": "clee-new-*",
"mappings": {
"clee-new": {
"_all": {
"enabled": true
},
"dynamic_templates": [
{
"string_fields": {
"match": "ipAddress*",
"match_mapping_type": "nested",
"mapping": {
"index": "not_analyzed",
"type": "ip"
}
}
}
]
}
}
}'
curl -XPUT localhost:9200/_template/clee-new-* -d '{
"template": "clee-new-*",
"mappings": {
"clee-new": {
"_all": {
"enabled": true
},
"dynamic_templates": [
{
"string_fields": {
"match": "ipAddress.bytes",
"match_mapping_type": "string",
"mapping": {
"index": "not_analyzed",
"type": "ip"
}
}
}
]
}
}
}'
答
得到这个与path_match工作
curl -XPUT localhost:9200/_template/clee-new -d '{
"template": "clee-new-*",
"mappings": {
"_default_": {
"_all": {
"enabled": true
},
"dynamic_templates": [
{
"string_fields": {
"path_match": "ipAddress.*",
"match_mapping_type": "*",
"mapping": {
"index": "not_analyzed",
"type": "ip"
}
}
}
]
}
}
}'