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

版本: 7.16-8.9

简而言之,当 Elasticsearch 尝试高亮显示搜索结果时,如果只定义了 pre_tags 而没有设置相应的 post_tags,就会出现此错误。pre_tags 和 post_tags 用于包裹搜索结果的高亮部分。要解决此问题,你应该确保在高亮请求中同时设置了 pre_tags 和 post_tags。如果你不需要任何特定的 post_tags,可以将其设置为空字符串。或者,如果你的用例不需要 pre_tags,也可以将其删除。

日志上下文 #

日志 “pre_tags are set but post_tags are not set” 的类名是 AbstractHighlighterBuilder.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考:

}; HIGHLIGHT_QUERY_FIELD);
 return (XContentParser p; HB hb) -> {
 try {
 parser.parse(p; hb; null);
 if (hb.preTags() != null && hb.postTags() == null) {
 throw new ParsingException(p.getTokenLocation(); "pre_tags are set but post_tags are not set");
 }
 } catch (IOException e) {
 throw new RuntimeException(e);
 }
 return hb;