# Dynamic\_templates with a match\_mapping\_type of "object"

**URL:** <https://discuss.elastic.co/t/dynamic-templates-with-a-match-mapping-type-of-object/7645>\
**Category:** Elasticsearch\
**Created:** [May 10, 2012, 10:29pm UTC](https://discuss.elastic.co/t/dynamic-templates-with-a-match-mapping-type-of-object/7645 "2012-05-10T22:29:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelB](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@MichaelB](https://discuss.elastic.co/u/MichaelB)\
**Post date:** [May 10, 2012, 10:29pm UTC](https://discuss.elastic.co/t/dynamic-templates-with-a-match-mapping-type-of-object/7645/1 "2012-05-10T22:29:16Z")

</div>

hello,  
I'm trying to use dynamic\_templates with a match\_mapping\_type of "object",  
and a mapping  
that suffixes the field name but leaves the type as object. Here my little  
sample script.

curl -XPUT '[http://localhost:9200/myindex](http://localhost:9200/myindex)'

body='{  
"mytype" : {  
"properties" : {  
"myroot" : {"type" : "object"}  
},  
"dynamic\_templates" : [  
{"mytemplate" : {  
"match" : "\*",  
"match\_mapping\_type" : "object",  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"{name}\_myext" : {"type": "object"}  
}  
}  
}}  
]  
}  
}'  
curl -XPUT '[http://localhost:9200/myindex/mytype/\_mapping](http://localhost:9200/myindex/mytype/_mapping)' -d "$body"

body='{"myroot" : {"myobj": {"name": "Victor  
Hugo"}}}'  
curl -XPOST '[http://localhost:9200/myindex/mytype](http://localhost:9200/myindex/mytype)' -d "$body"

When executing the script I see the following exception in the es log.

org.elasticsearch.index.mapper.MapperParsingException: No type specified  
for property [myobj\_myext]  
at  
org.elasticsearch.index.mapper.multifield.MultiFieldMapper$TypeParser.parse(MultiFieldMapper.java:122)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:256)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:256)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:162)  
at  
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:269)  
at  
org.elasticsearch.cluster.metadata.MetaDataMappingService$2.execute(MetaDataMappingService.java:185)  
at  
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:680)

What am I doing wrong here? Any hint appreciated.

thanks for your help,  
Michael

---

<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:** [May 13, 2012, 9:58am UTC](https://discuss.elastic.co/t/dynamic-templates-with-a-match-mapping-type-of-object/7645/2 "2012-05-13T09:58:13Z")

</div>

You can't replace an object type with a multi field type, it will cause  
failures to parse the data. Multi field mapping can only apply on "core"  
field types, no object ones.

On Fri, May 11, 2012 at 1:29 AM, MichaelB [michael.beisiegel@gmail.com](mailto:michael.beisiegel@gmail.com)wrote:

> hello,  
> I'm trying to use dynamic\_templates with a match\_mapping\_type of "object",  
> and a mapping  
> that suffixes the field name but leaves the type as object. Here my little  
> sample script.
> 
> curl -XPUT '[http://localhost:9200/myindex](http://localhost:9200/myindex)'
> 
> body='{  
> "mytype" : {  
> "properties" : {  
> "myroot" : {"type" : "object"}  
> },  
> "dynamic\_templates" : [  
> {"mytemplate" : {  
> "match" : "\*",  
> "match\_mapping\_type" : "object",  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "{name}\_myext" : {"type": "object"}  
> }  
> }  
> }}  
> ]  
> }  
> }'  
> curl -XPUT '[http://localhost:9200/myindex/mytype/\_mapping](http://localhost:9200/myindex/mytype/_mapping)' -d "$body"
> 
> body='{"myroot" : {"myobj": {"name": "Victor  
> Hugo"}}}'  
> curl -XPOST '[http://localhost:9200/myindex/mytype](http://localhost:9200/myindex/mytype)' -d "$body"
> 
> When executing the script I see the following exception in the es log.
> 
> org.elasticsearch.index.mapper.MapperParsingException: No type specified  
> for property [myobj\_myext]  
> at  
> org.elasticsearch.index.mapper.multifield.MultiFieldMapper$TypeParser.parse(MultiFieldMapper.java:122)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:256)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:256)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)  
> at  
> org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:162)  
> at  
> org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:269)  
> at  
> org.elasticsearch.cluster.metadata.MetaDataMappingService$2.execute(MetaDataMappingService.java:185)  
> at  
> org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:680)
> 
> What am I doing wrong here? Any hint appreciated.
> 
> thanks for your help,  
> Michael

---

<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, 3:29am UTC](https://discuss.elastic.co/t/dynamic-templates-with-a-match-mapping-type-of-object/7645/3 "2017-07-06T03:29:05Z")

</div>


