Skip to content

Commit b4cd818

Browse files
committed
improve deprecation warnings for invalid match_mapping_type values
1 parent 31cc5ed commit b4cd818

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static XContentFieldType fromString(String value) {
155155
return v;
156156
}
157157
}
158-
throw new IllegalArgumentException("No xcontent type matched on [" + value + "], possible values are "
158+
throw new IllegalArgumentException("No field type matched on [" + value + "], possible values are "
159159
+ Arrays.toString(values()));
160160
}
161161

@@ -208,12 +208,8 @@ public static DynamicTemplate parse(String name, Map<String, Object> conf,
208208
try {
209209
xcontentFieldType = XContentFieldType.fromString(matchMappingType);
210210
} catch (IllegalArgumentException e) {
211-
// TODO: do this in 6.0
212-
/*if (indexVersionCreated.onOrAfter(Version.V_6_0_0)) {
213-
throw e;
214-
}*/
215-
216-
DEPRECATION_LOGGER.deprecated("Ignoring unrecognized match_mapping_type: [" + matchMappingType + "]");
211+
DEPRECATION_LOGGER.deprecated("match_mapping_type [" + matchMappingType + "] is invalid and will be ignored: "
212+
+ e.getMessage());
217213
// this template is on an unknown type so it will never match anything
218214
// null indicates that the template should be ignored
219215
return null;

core/src/test/java/org/elasticsearch/index/mapper/DynamicTemplateTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void testParseUnknownMatchType() throws IOException {
5656
templateDef.put("mapping", Collections.singletonMap("store", true));
5757
// if a wrong match type is specified, we ignore the template
5858
assertNull(DynamicTemplate.parse("my_template", templateDef, Version.V_5_0_0_alpha5));
59-
//TODO clarify this deprecation warning
60-
assertWarnings("Ignoring unrecognized match_mapping_type: [short]");
59+
assertWarnings("match_mapping_type [short] is invalid and will be ignored: No field type matched on [short], " +
60+
"possible values are [object, string, long, double, boolean, date, binary]");
6161
}
6262

6363
public void testMatchAllTemplate() {

0 commit comments

Comments
 (0)