Pre tags are set but post tags are not set – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.16-8.9

Briefly, this error occurs when Elasticsearch is trying to highlight search results, but only the pre_tags are defined without corresponding post_tags. The pre_tags and post_tags are used to wrap the highlighted parts of the search results. To resolve this issue, you should ensure that both pre_tags and post_tags are set in your highlighting request. If you don’t want any specific post_tags, you can set it to an empty string. Alternatively, you can remove the pre_tags if they are not necessary for your use case.

This guide will help you check for common problems that cause the log ” pre_tags are set but post_tags are not set ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search.

Log Context

Log “pre_tags are set but post_tags are not set” class name is AbstractHighlighterBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 }; 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;

 

 [ratemypost]

Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.