Dynamic templates - Why is this configuration not working?

Hi all,

I am looking for help on my dynamic templates.
I figured that this confguration is not working :
{
"article":
{
"default" : {
"dynamic_templates":
[{
"template_raw":
{
"match" : "_raw",
"mapping" :
{
"type" : "string",
"index" : "not_analyzed",
"store" : "yes"
}
},
"template_basic": {
"match": "
",
"mapping": {
"type": "{dynamic_type}",
"index" : "analyzed"
}
}
}]
},
"_all":
{
"enabled" : true
},
"_analyzer" : {
"default" : {
"type" : "default"
}
},
"properties":
{
"id":
{
"type":"long",
"index": "no",
"store":"no"
},
"slug":
{
"type":"string",
"index": "not_analyzed",
"store":"no"
},
"code":
{
"type":"string",
"index": "not_analyzed",
"store":"yes",
"boost": 5.0
}
...
}
}
}

No errors during index creation and mapping pushing.
But my mapping does take in account this confuguration.

If I remoce the ""default" and setting the templates configuration on the
parent level, i have the error on mapping definition : "MapperParsingException[A
dynamic template must be defined with a name]".

How should I define this dynamic template ? Sorry for the noob question but
I falied in this little stuff.

Sylvain

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/74deebd2-c847-4d57-8c0f-eea6b54d71ab%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Your problem is related to a mistake in the "dynamic_template" definition. It must have the next form:

"dynamic_templates": [
    {
                "template_raw": {
                    "match"     : "*_raw",
                    "mapping"   : {
                        "type"              : "string",
                        "index"             : "not_analyzed",
                        "store"             : "yes"
                    }
                }
    },
    {
                "template_basic": {
                    "match": "*",
                    "mapping": {
                        "type": "{dynamic_type}",
                        "index" : "analyzed"
                    }
                }
     }
]

So, the difference is that every dynamic template should be separated as another dict in the list of dynamic templates.

1 Like