0

How do i setup dynamic template for a mapping below

      "ipAddress" : {
        "properties" : {
          "bytes" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      },

I have tried multiple options like but not able to pine out how to change the text/string field to a ip data type. I am guessing this is due to nesting but I am new to dynamic templates and not sure how to construct one

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"
                    }
                }
            }
        ]
    }
}
}'

1 Answers1

0

Got this to work with 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"
                    }
                }
            }
        ]
    }
}
}'