# Add multiple path\_match in dynamic templates

**URL:** https://discuss.elastic.co/t/add-multiple-path-match-in-dynamic-templates/190908
**Category:** Elasticsearch
**Created:** [July 17, 2019, 8:00am UTC](https://discuss.elastic.co/t/add-multiple-path-match-in-dynamic-templates/190908 "2019-07-17T08:00:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tomeri](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@tomeri](https://discuss.elastic.co/u/tomeri)
#### Post date: [July 17, 2019, 8:00am UTC](https://discuss.elastic.co/t/add-multiple-path-match-in-dynamic-templates/190908/1 "2019-07-17T08:00:09Z")

</div>

Hi,

I use dynamic mapping with some dynamic templates that I customized  
I'm trying to block the adding of new fields from type **object** by default, along with whitelisting some specific object fields.

Here is the mapping I've created.

```
{
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "exclude_unspported_fields_name": {
            "match_pattern": "regex",
            "mapping": {
              "type": "object",
              "enabled": false
            },
            "match_mapping_type": "*",
            "match": "^[^a-zA-Z@_].*"
          }
        },
        {
          "message_field": {
            "path_match": "message",
            "mapping": {
              "norms": false,
              "type": "text"
            },
            "match_mapping_type": "string"
          }
        },
        {
          "string_fields": {
            "mapping": {
              "norms": false,
              "type": "text",
              "fields": {
                "keyword": {
                  "ignore_above": 256,
                  "type": "keyword"
                }
              }
            },
            "match_mapping_type": "string",
            "match": "*"
          }
        },
        {
          "kubernetes_field": {
            "mapping": {
              "dynamic": true
            },
            "path_match": "kubernetes*"
          }
        },
        {
          "beats_field": {
            "mapping": {
              "dynamic": true
            },
            "path_match": "beat*"
          }
        },
        {
          "log_field": {
            "mapping": {
              "dynamic": true
            },
            "path_match": "log*"
          }
        },
        {
      "exclude_object_fields": {
        "mapping": {
          "dynamic": false
        },
        "match_mapping_type": "object",
        "match": "*"
      }
    }
  ],
  "properties": {
    "@timestamp": {
      "type": "date"
    },
    "geoip": {
      "dynamic": true,
      "properties": {
        "ip": {
          "type": "ip"
        },
        "latitude": {
          "type": "half_float"
        },
        "location": {
          "type": "geo_point"
        },
        "longitude": {
          "type": "half_float"
        }
      }
    },
    "@version": {
      "type": "keyword"
    }
  }
}

```

In the **exclude\_object\_fields** section, I disable the dynamic adding of new object fields.  
Just before that, I configured **kubernetes\_field** , **beats\_field** , **log\_field** to enable these objects and their subobjects.

My question is, is there a way to specify a multiple **path\_match** within the same dynamic template block? or use it with regex (i.e _kubernetes\*_|_beats\*_|_log\*_) or any other way to simplify the "whitelisted" fields? let's say I need to whitelist 50 fields.

Thanks,

---

<div class="post-metadata">

### Author: ![tomeri](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@tomeri](https://discuss.elastic.co/u/tomeri)
#### Post date: [July 21, 2019, 8:34am UTC](https://discuss.elastic.co/t/add-multiple-path-match-in-dynamic-templates/190908/2 "2019-07-21T08:34:21Z")

</div>

Any idea?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 18, 2019, 8:45am UTC](https://discuss.elastic.co/t/add-multiple-path-match-in-dynamic-templates/190908/3 "2019-08-18T08:45:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
