Dynamic_templates with a match_mapping_type of "object"

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'

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' -d "$body"

body='{"myroot" : {"myobj": {"name": "Victor
Hugo"}}}'
curl -XPOST '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

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.comwrote:

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'

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' -d "$body"

body='{"myroot" : {"myobj": {"name": "Victor
Hugo"}}}'
curl -XPOST '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