版本: 7.11-8.9
简要来说,当创建 Elasticsearch 索引模板时未指定映射(mapping)或运行时(runtime)字段时,就会出现此错误。Elasticsearch 中的索引模板至少需要其中之一来定义索引中的字段应如何存储和搜索。要解决此问题,您可以在索引模板中添加映射或运行时字段。映射定义了字段的数据类型,而运行时字段允许您定义将在查询时计算的字段。
日志上下文 #
日志 “template [” + name + “] must have either mapping or runtime set” 的类名是 DynamicTemplate.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
// so we need to ignore them at parsing time for old indices
throw new IllegalArgumentException("Illegal dynamic template parameter: [" + propName + "]");
}
}
if (mapping == null) {
throw new MapperParsingException("template [" + name + "] must have either mapping or runtime set");
} final XContentFieldType[] xContentFieldTypes;
if ("*".equals(matchMappingType) || (matchMappingType == null && matchPatternsAreDefined(match; pathMatch))) {
if (runtime) {





