diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index f3248859dbb..aefc91da9d9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -603,7 +603,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { // we need to do it here so we can handle things like attachment templates, where calling // text (to see if its a date) causes the binary value to be cleared if (!resolved) { - Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string"); + Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string", null); if (builder != null) { mapper = builder.build(builderContext); resolved = true; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java index 44a68f67727..60f565eb4d2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java @@ -202,7 +202,11 @@ public class RootObjectMapper extends ObjectMapper { } public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType) { - DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, dynamicType); + return findTemplateBuilder(context, name, dynamicType, dynamicType); + } + + public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, String matchType) { + DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType); if (dynamicTemplate == null) { return null; } @@ -215,9 +219,9 @@ public class RootObjectMapper extends ObjectMapper { return typeParser.parse(name, dynamicTemplate.mappingForName(name, dynamicType), parserContext); } - public DynamicTemplate findTemplate(ContentPath path, String name, String dynamicType) { + public DynamicTemplate findTemplate(ContentPath path, String name, String matchType) { for (DynamicTemplate dynamicTemplate : dynamicTemplates) { - if (dynamicTemplate.match(path, name, dynamicType)) { + if (dynamicTemplate.match(path, name, matchType)) { return dynamicTemplate; } }