# Dynamic\_templates

**URL:** <https://discuss.elastic.co/t/dynamic-templates/188687>\
**Category:** Elasticsearch\
**Created:** [July 3, 2019, 10:30am UTC](https://discuss.elastic.co/t/dynamic-templates/188687 "2019-07-03T10:30:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wagoon](https://avatars.discourse-cdn.com/v4/letter/w/e9c0ed/32.png) [@wagoon](https://discuss.elastic.co/u/wagoon)\
**Post date:** [July 3, 2019, 10:30am UTC](https://discuss.elastic.co/t/dynamic-templates/188687/1 "2019-07-03T10:30:34Z")

</div>

I want to create dynamic\_template mapping for this document:

```auto
{
	"COUNT:integer":1,
	"one":{
		"COUNT:integer":1,
		"two":{
			"COUNT:integer":1,
			"three":{
				"COUNT:integer":1,
			}
		}
	}
}
```

My goal is to create something like:

```auto
"mappings" : {
	"dynamic_templates":[
		{
			"integer":{
				"match": "*:integer",
				"match_mapping_type": "*",   
				"mapping": {"type":"integer"}
			}
		}	
	]
}
```

My question:  
will this mapping match all "COUNT:integer" values, including `one.COUNT:integer`, `one.two.COUNT:integer` and `one.two.three.COUNT:integer`?  
(And how to test, witch attributes matches this expression?)

If not, how to change mapping to achieve this goal?

- possible solution 1: `match_pattern` and `Regex`. Is `regex` testing whole path (`one.two.three.COUNT:integer`) or just attribute name `COUNT:integer`?
- possible solution 2: `path_match`. In documentation is not specified, if `"path_match":"*.*:integer"` matches only `one.COUNT:integer`, or if it matches also `COUNT:integer` and `one.two.COUNT:integer` and `one.two.three.COUNT:integer`

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 3, 2019, 2:07pm UTC](https://discuss.elastic.co/t/dynamic-templates/188687/2 "2019-07-03T14:07:25Z")

</div>

Hey,

how about testing it by creating an index with the above dynamic template and then index a document?

```auto
DELETE my_index

PUT my_index
{
  "mappings": {
    "dynamic_templates": [
      {
        "integer": {
          "match": "*:integer",
          "mapping": {
            "type": "integer"
          }
        }
      }
    ]
  }
}

PUT my_index/_doc/1
{
	"COUNT:integer":1,
	"one":{
		"COUNT:integer":1,
		"two":{
			"COUNT:integer":1,
			"three":{
				"COUNT:integer":1
			}
		}
	}
}

GET my_index/_mapping

```

retrieving the mapping. You can play around with the type and set it to a `double` to see if that actually works despite sending an integer to Elasticsearch.

--Alex

---

<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:** [July 31, 2019, 2:07pm UTC](https://discuss.elastic.co/t/dynamic-templates/188687/3 "2019-07-31T14:07:32Z")

</div>

Closed on July 31, 2019, 2:07pm UTC

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