版本: 7-7.15
简而言之,当 Elasticsearch 期望分析器被定义为字符串类型,但遇到不同的数据类型时,会出现此错误。这可能是由于映射或设置中的配置或语法不正确导致的。要解决此问题,请确保在设置中正确地将分析器定义为字符串。另外,检查您的映射并确保您尝试分析的字段是 “text” 类型,而不是 “keyword” 或任何其他不可分析的类型。
日志上下文 #
日志 “expecting the analyzer at [{}] to be a String; but found [{}] instead” 的类名是 TermVectorsRequest.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
Map<String, String> mapStrStr = new HashMap<>();
for (Map.Entry<String, Object> e : map.entrySet()) {
if (e.getValue() instanceof String) {
mapStrStr.put(e.getKey(), (String) e.getValue());
} else {
throw new ElasticsearchParseException("expecting the analyzer at [{}] to be a String; but found [{}] instead",
e.getKey(), e.getValue().getClass());
}
}
return mapStrStr;
}





