Mapping: dynamic templates of object type do not initialize some mapping data structures (like analyzers lookup), closes #929.

This commit is contained in:
kimchy 2011-05-13 14:52:09 +03:00
parent d61ba5c189
commit f02f63cf75
1 changed files with 9 additions and 1 deletions

View File

@ -336,7 +336,7 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
}
}
private void serializeObject(ParseContext context, String currentFieldName) throws IOException {
private void serializeObject(final ParseContext context, String currentFieldName) throws IOException {
context.path().add(currentFieldName);
XContentMapper objectMapper = mappers.get(currentFieldName);
@ -367,6 +367,14 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
objectMapper = builder.build(builderContext);
putMapper(objectMapper);
// we need to traverse in case we have a dynamic template and need to add field mappers
// introduced by it
objectMapper.traverse(new FieldMapperListener() {
@Override public void fieldMapper(FieldMapper fieldMapper) {
context.docMapper().addFieldMapper(fieldMapper);
}
});
// now re add it and parse...
context.path().add(currentFieldName);
objectMapper.parse(context);