# Issue with Dynamic Template

**URL:** <https://discuss.elastic.co/t/issue-with-dynamic-template/83974>\
**Category:** Elasticsearch\
**Created:** [April 28, 2017, 7:14am UTC](https://discuss.elastic.co/t/issue-with-dynamic-template/83974 "2017-04-28T07:14:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elk\_user1](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@elk\_user1](https://discuss.elastic.co/u/elk_user1)\
**Post date:** [April 28, 2017, 7:14am UTC](https://discuss.elastic.co/t/issue-with-dynamic-template/83974/1 "2017-04-28T07:14:31Z")

</div>

Hi there,

I am trying to use dynamic templates for mapping any new incoming text fields to multifields with text and keyword. I'm facing two issues here :

1. I'm using regex for matching field name and it doesn't seem to be working as expected
2. ignore\_above:256 appears in mapping by default and I don't want that as any values with more than 256 length has also to be considered in our use case.

Below is the mapping which I am currently working on. If I add any new field named abc.xyz.test, which doesn't come under the match criteria, still it is being indexed.

Any help is appreciated. Thanks in advance.

```
PUT test-dynamic-template
{
    "mappings": {
        "test-type": {     
        	"_all": {
				"enabled": false
			},
             "dynamic_templates": [
                { "allFields": {
                      "match_mapping_type": "*",
                      "match": "abc.xyz.http://test-url.com/extension*", 
                      
                      "mapping": {
                             "type": "text",
									"fields": {
										"keyword": {
											"type": "keyword"
										}
									}
                      }
                }}],
                
			"properties": {
				
				"abc": {
					"properties": {
						"xyz": {
							"properties": {
								"http://test-url.com/extension/user-id": {
									"type": "long",
									"fields": {
										"keyword": {
											"type": "keyword"
										}
									}
								},
								"http://test-url.com/extension/username": {
									"type": "text",
									"fields": {
										"keyword": {
											"type": "keyword"
										}
									}
								}

							}

						}
					}
				},

				"timestamp": {
					"type": "date",
					"format": "yyy-MM-dd HH:mm:ss",
					"fields": {
						"keyword": {
							"type": "keyword"
						}
					}
				},
				"version": {
					"type": "text",
					"fields": {
						"keyword": {
							"type": "keyword"
						}
					}
				}
			}
		}
	}
}

```

Thanks,  
Deepti

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 28, 2017, 7:49am UTC](https://discuss.elastic.co/t/issue-with-dynamic-template/83974/2 "2017-04-28T07:49:25Z")

</div>

That sort of fieldname is likely to cause a mapping explosion, and subsequently, lots of sparse data.  
I think you'd be better off creating a nested field with something like this;

```auto
  "fieldname": "abc.xyz.http://test-url.com/extension(whatevervalue)",
  "fieldvalue": "the actual keyword value"

```

---

<div class="post-metadata">

**Author:** ![elk\_user1](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@elk\_user1](https://discuss.elastic.co/u/elk_user1)\
**Post date:** [April 28, 2017, 7:54am UTC](https://discuss.elastic.co/t/issue-with-dynamic-template/83974/3 "2017-04-28T07:54:11Z")

</div>

Hello,

Thanks for the response, but I really don't have control over the field names. Could you please help me understand the dynamic template and the ignore\_above setting which is dynamically created? I mentioned these in my issue.

Thanks,  
Deepti

---

<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:** [May 26, 2017, 7:58am UTC](https://discuss.elastic.co/t/issue-with-dynamic-template/83974/4 "2017-05-26T07:58:56Z")

</div>

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