2017-06-13 91 views
0

我怎麼下面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" 
        } 
       } 
      } 
     ] 
    } 
} 
}' 

回答

0

得到這個與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" 
        } 
       } 
      } 
     ] 
    } 
} 
}'