# Issue with application of dynamic templates

**URL:** <https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573>\
**Category:** Elasticsearch\
**Created:** [November 15, 2010, 7:21pm UTC](https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573 "2010-11-15T19:21:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diptamay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/diptamay/32/2805_2.png) [@Diptamay](https://discuss.elastic.co/u/Diptamay)\
**Post date:** [November 15, 2010, 7:21pm UTC](https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573/1 "2010-11-15T19:21:46Z")

</div>

Hey

Just saw this. Maybe I am doing something wrong, or could be a  
possible bug with dynamic templates. Code to reproduce is at  
[git@github.com](mailto:git@github.com):diptamay/es-issue.git. ES version is latest trunk.

## Scenario:

When dynamic templates are defined in seed mappings, they get  
correctly applied ONLY when ONE template is define and not when  
multiple templates are present.

## Steps to setup and reproduce:

1. Ensure ES is running at localhost:9200 (look at configuration  
below)
2. run ./automate.sh.  
a) This will create an es-test index with the seed mappings and  
load the sample data.  
b) Then it fires a query which returns results correctly.
3. Now look at the metadata generated by ES.  
a) You will see that the dynamic templates got applied for the  
"video" type.  
b) You will see the templates did not kick in for the "lineup"  
type. Note: multiple templates have been provided for lineup in the  
seed.

## Configuration of ES:

cluster:  
name: sanyal  
gateway:  
type: fs  
fs:  
location: /Users/sanyal/Documents/workspace/hb\_indices  
index:  
memory:  
enabled: true  
gateway:  
snapshot\_interval : 30s  
store:  
type: niofs  
number\_of\_shards : 2  
number\_of\_replicas : 1  
path:  
home: /Users/sanyal/Installs/elasticsearch  
logs: /Users/sanyal/Documents/workspace/logs

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 16, 2010, 8:55am UTC](https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573/2 "2010-11-16T08:55:24Z")

</div>

Hi,

The definition for more than one template you have in the lineup mapping  
is incorrect, here is the correct one (its an array of json objects):

```
    "dynamic_templates" : [
        {
            "template_1" : {
                "path_match" : "fields.umpire_id_*",
                "mapping" : {
                    "type" : "string",
                    "index" : "not_analyzed"
                }
            }
        },
        {
            "template_2" : {
                "path_match" : "tags.*.value",
                "mapping" : {
                    "type" : "string",
                    "index" : "not_analyzed"
                }
            }
        }
    ]

```

-shay.banon

On Mon, Nov 15, 2010 at 9:21 PM, diptamay [diptamay@gmail.com](mailto:diptamay@gmail.com) wrote:

> Hey
> 
> Just saw this. Maybe I am doing something wrong, or could be a  
> possible bug with dynamic templates. Code to reproduce is at  
> [git@github.com](mailto:git@github.com):diptamay/es-issue.git. ES version is latest trunk.
> 
> ## Scenario:
> 
> When dynamic templates are defined in seed mappings, they get  
> correctly applied ONLY when ONE template is define and not when  
> multiple templates are present.
> 
> ## Steps to setup and reproduce:
> 
> 1. Ensure ES is running at localhost:9200 (look at configuration  
> below)
> 2. run ./automate.sh.  
> a) This will create an es-test index with the seed mappings and  
> load the sample data.  
> b) Then it fires a query which returns results correctly.
> 3. Now look at the metadata generated by ES.  
> a) You will see that the dynamic templates got applied for the  
> "video" type.  
> b) You will see the templates did not kick in for the "lineup"  
> type. Note: multiple templates have been provided for lineup in the  
> seed.
> 
> ## Configuration of ES:
> 
> cluster:  
> name: sanyal  
> gateway:  
> type: fs  
> fs:  
> location: /Users/sanyal/Documents/workspace/hb\_indices  
> index:  
> memory:  
> enabled: true  
> gateway:  
> snapshot\_interval : 30s  
> store:  
> type: niofs  
> number\_of\_shards : 2  
> number\_of\_replicas : 1  
> path:  
> home: /Users/sanyal/Installs/elasticsearch  
> logs: /Users/sanyal/Documents/workspace/logs

---

<div class="post-metadata">

**Author:** ![Diptamay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/diptamay/32/2805_2.png) [@Diptamay](https://discuss.elastic.co/u/Diptamay)\
**Post date:** [November 16, 2010, 3:26pm UTC](https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573/3 "2010-11-16T15:26:32Z")

</div>

My apologies for missing that.

Thanks  
Diptamay

On Nov 16, 3:55 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Hi,
> 
> The definition for more than one template you have in the lineup mapping  
> is incorrect, here is the correct one (its an array of json objects):
> 
> ```
> "dynamic_templates" : [
> {
> "template_1" : {
> "path_match" : "fields.umpire_id_*",
> "mapping" : {
> "type" : "string",
> "index" : "not_analyzed"
> }
> }
> },
> {
> "template_2" : {
> "path_match" : "tags.*.value",
> "mapping" : {
> "type" : "string",
> "index" : "not_analyzed"
> }
> }
> }
> ]
> 
> ```
> 
> -shay.banon
> 
> On Mon, Nov 15, 2010 at 9:21 PM, diptamay [dipta...@gmail.com](mailto:dipta...@gmail.com) wrote:
> 
> > Hey
> 
> > Just saw this. Maybe I am doing something wrong, or could be a  
> > possible bug with dynamic templates. Code to reproduce is at  
> > [g...@github.com](mailto:g...@github.com):diptamay/es-issue.git. ES version is latest trunk.
> 
> > ## Scenario:
> > 
> > When dynamic templates are defined in seed mappings, they get  
> > correctly applied ONLY when ONE template is define and not when  
> > multiple templates are present.
> 
> > ## Steps to setup and reproduce:
> > 
> > 1. Ensure ES is running at localhost:9200 (look at configuration  
> > below)
> > 2. run ./automate.sh.  
> > a) This will create an es-test index with the seed mappings and  
> > load the sample data.  
> > b) Then it fires a query which returns results correctly.
> > 3. Now look at the metadata generated by ES.  
> > a) You will see that the dynamic templates got applied for the  
> > "video" type.  
> > b) You will see the templates did not kick in for the "lineup"  
> > type. Note: multiple templates have been provided for lineup in the  
> > seed.
> 
> > ## Configuration of ES:
> > 
> > cluster:  
> > name: sanyal  
> > gateway:  
> > type: fs  
> > fs:  
> > location: /Users/sanyal/Documents/workspace/hb\_indices  
> > index:  
> > memory:  
> > enabled: true  
> > gateway:  
> > snapshot\_interval : 30s  
> > store:  
> > type: niofs  
> > number\_of\_shards : 2  
> > number\_of\_replicas : 1  
> > path:  
> > home: /Users/sanyal/Installs/elasticsearch  
> > logs: /Users/sanyal/Documents/workspace/logs

---

<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 6, 2017, 4:16am UTC](https://discuss.elastic.co/t/issue-with-application-of-dynamic-templates/3573/4 "2017-07-06T04:16:25Z")

</div>


