版本: 7.16-8.9
简而言之,当 Elasticsearch 中分配给字段的值的数据类型既不是数字也不是字符串时,就会发生此错误。Elasticsearch 要求数据类型与为索引定义的映射保持一致。要解决此问题,请确保值的数据类型与字段的映射匹配。如果未定义映射,Elasticsearch 将尝试根据第一个索引的文档推断数据类型。您也可以显式定义字段的映射以避免此类问题。
日志上下文 #
日志 “Property [value] on field [” + n + “] must be a number or a string; but got [” + o + “]” 类名是 ConstantKeywordFieldMapper.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
// This is defined as updateable because it can be updated once; from [null] to any value;
// by a dynamic mapping update. Once it has been set; however; the value cannot be changed.
private final Parametervalue = new Parameter<>("value"; true; () -> null; (n; c; o) -> {
if (o instanceof Number == false && o instanceof CharSequence == false) {
throw new MapperParsingException("Property [value] on field [" + n + "] must be a number or a string; but got [" + o + "]");
}
return o.toString();
}; m -> toType(m).fieldType().value; XContentBuilder::field; Objects::toString);
private final Parameter> meta = Parameter.metaParam();





