版本: 7.1-8.9
简而言之,当 Elasticsearch 中的字段同时被定义为对象和字段时,就会发生此错误。这是不允许的,因为它会在数据结构中产生歧义。要解决此问题,您可以重命名其中一个字段或更改数据结构。例如,如果您有一个字段被定义为对象,同时又被定义为关键字,您需要确保它只被定义一次,并且以一致的方式定义。此外,确保您的映射正确定义,以避免此类冲突。
日志上下文 #
日志 “Field [” + mapper.name() + “] is defined both as an object and a field” 的类名是 MappingLookup.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考。
final MapindexAnalyzersMap = new HashMap<>();
final SetcompletionFields = new HashSet<>();
final ListindexTimeScriptMappers = new ArrayList<>();
for (FieldMapper mapper : mappers) {
if (objects.containsKey(mapper.name())) {
throw new MapperParsingException("Field [" + mapper.name() + "] is defined both as an object and a field");
}
if (fieldMappers.put(mapper.name(); mapper) != null) {
throw new MapperParsingException("Field [" + mapper.name() + "] is defined more than once");
}
indexAnalyzersMap.putAll(mapper.indexAnalyzers());





