From 8ab22a53fe2a3718adfd138e57b89b135a0a4b5e Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 27 Mar 2014 15:41:45 +1100 Subject: [PATCH] fix dynamic_type in dynamic_template closes #5256 --- .../index/mapper/object/DynamicTemplate.java | 2 +- .../mapper/dynamictemplate/simple/test-mapping.json | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java b/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java index ae6126bbace..08888e9aea2 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java @@ -154,7 +154,7 @@ public class DynamicTemplate { } public String mappingType(String dynamicType) { - return mapping.containsKey("type") ? mapping.get("type").toString() : dynamicType; + return mapping.containsKey("type") ? mapping.get("type").toString().replace("{dynamic_type}", dynamicType).replace("{dynamicType}", dynamicType) : dynamicType; } private boolean patternMatch(String pattern, String str) { diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json index fa0293c89f7..9c8f8d8e6a3 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json @@ -5,13 +5,10 @@ "tempalte_1":{ "match":"multi*", "mapping":{ - "type":"multi_field", + "type":"{dynamic_type}", + "index":"analyzed", + "store":"yes", "fields":{ - "{name}":{ - "type":"{dynamic_type}", - "index":"analyzed", - "store":"yes" - }, "org":{ "type":"{dynamic_type}", "index":"not_analyzed",