版本: 6.8-7.1
简要地说,当创建Elasticsearch索引模板时未指定映射,就会出现此错误。映射是必不可少的,因为它定义了字段的类型以及它们应该如何被存储和索引。要解决这个问题,你可以为模板添加映射,或者如果不需要该模板则将其删除。如果你不确定如何设置映射,可以使用"get mapping" API来获取现有索引的映射作为参考。
日志上下文 #
日志"template must have mapping set"的类名是 DynamicTemplate.java。我们从Elasticsearch源代码中提取了以下内容,供那些需要深入了解上下文的人员参考:
if (match == null && pathMatch == null && matchMappingType == null) {
throw new MapperParsingException("template must have match; path_match or match_mapping_type set " + conf.toString());
}
if (mapping == null) {
throw new MapperParsingException("template must have mapping set");
} XContentFieldType xcontentFieldType = null;
if (matchMappingType != null && matchMappingType.equals("*") == false) {
try {





