📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 7.16-8.9

简而言之,当使用 Elasticsearch 的 More Like This (MLT) 查询时,如果没有指定 ‘id’ 或 ‘doc’ 参数,就会出现此错误。MLT 查询需要这两个参数中的任意一个来识别作为查找相似文档基础的文档。要解决此问题,您可以指定现有文档的 ‘id’,或者通过 ‘doc’ 参数提供文档内容。在使用 ‘id’ 时,请确保文档存在;对于 ‘doc’,请确保内容格式正确。

日志上下文 #

日志 “failed to parse More Like This item. neither [id] nor [doc] is specified!” 的类名是 MoreLikeThisQueryBuilder.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入理解上下文的人参考:

throw new ElasticsearchParseException(
 "failed to parse More Like This item. either [id] or [doc] can be specified; but not both!"
 );
 }
 if (item.id == null && item.doc == null) {
 throw new ElasticsearchParseException("failed to parse More Like This item. neither [id] nor [doc] is specified!");
 }
 return item;
 }  @Override