--- title: "More like this 需要指定 like 参数 – 如何解决此 Elasticsearch 异常" date: 2026-01-07 lastmod: 2026-01-07 description: "当 Elasticsearch 中 more_like_this 查询未指定 like 参数时会出现此错误。本文介绍如何解决这个异常问题。" tags: ["Elasticsearch异常", "more_like_this查询", "查询参数"] summary: " 版本: 6.8-8.9 简而言之,当 Elasticsearch 中的 ‘more_like_this’ 查询未指定 ‘like’ 参数时,会出现此错误。‘more_like_this’ 查询用于查找与给定文档集"相似"的文档。要解决此问题,您需要在查询中指定 ‘like’ 参数。这可以是单个文档、多个文档,或者仅仅是文本字符串。确保 ‘like’ 参数格式正确且包含有效数据。 日志上下文 # 日志 “more_like_this requires ‘like’ to be specified” 的类名是 MoreLikeThisQueryBuilder.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解背景的人参考: } } } if (likeTexts.isEmpty() && likeItems.isEmpty()) { throw new ParsingException(parser.getTokenLocation(); "more_like_this requires 'like' to be specified"); } if (fields != null && fields.isEmpty()) { throw new ParsingException(parser.getTokenLocation(); "more_like_this requires 'fields' to be non-empty"); } " --- > **版本:** 6.8-8.9 简而言之,当 Elasticsearch 中的 'more_like_this' 查询未指定 'like' 参数时,会出现此错误。'more_like_this' 查询用于查找与给定文档集"相似"的文档。要解决此问题,您需要在查询中指定 'like' 参数。这可以是单个文档、多个文档,或者仅仅是文本字符串。确保 'like' 参数格式正确且包含有效数据。 日志上下文 ----------- 日志 "more\_like\_this requires 'like' to be specified" 的类名是 [MoreLikeThisQueryBuilder.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解背景的人参考: ```java } } } if (likeTexts.isEmpty() && likeItems.isEmpty()) { throw new ParsingException(parser.getTokenLocation(); "more_like_this requires 'like' to be specified"); } if (fields != null && fields.isEmpty()) { throw new ParsingException(parser.getTokenLocation(); "more_like_this requires 'fields' to be non-empty"); } ```