Class DefaultPassageFormatter
java.lang.Object
org.apache.lucene.search.uhighlight.PassageFormatter
org.apache.lucene.search.uhighlight.DefaultPassageFormatter
Creates a formatted snippet from the top passages.
The default implementation marks the query terms as bold, and places ellipses between unconnected passages.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
text that will appear between two unconnected passagesprotected final boolean
true if we should escape for htmlprotected final String
text that will appear after highlighted termsprotected final String
text that will appear before highlighted terms -
Constructor Summary
ConstructorDescriptionCreates a new DefaultPassageFormatter with the default tags.DefaultPassageFormatter
(String preTag, String postTag, String ellipsis, boolean escape) Creates a new DefaultPassageFormatter with custom tags. -
Method Summary
-
Field Details
-
preTag
text that will appear before highlighted terms -
postTag
text that will appear after highlighted terms -
ellipsis
text that will appear between two unconnected passages -
escape
protected final boolean escapetrue if we should escape for html
-
-
Constructor Details
-
DefaultPassageFormatter
public DefaultPassageFormatter()Creates a new DefaultPassageFormatter with the default tags. -
DefaultPassageFormatter
Creates a new DefaultPassageFormatter with custom tags.- Parameters:
preTag
- text which should appear before a highlighted term.postTag
- text which should appear after a highlighted term.ellipsis
- text which should be used to connect two unconnected passages.escape
- true if text should be html-escaped
-
-
Method Details
-
format
Description copied from class:PassageFormatter
Formats the toppassages
fromcontent
into a human-readable text snippet.- Specified by:
format
in classPassageFormatter
- Parameters:
passages
- top-N passages for the field. Note these are sorted in the order that they appear in the document for convenience.content
- content for the field.- Returns:
- formatted highlight. Note that for the non-expert APIs in
UnifiedHighlighter
that return String, the toString method on the Object returned by this method is used to compute the string.
-
append
Appends original text to the response.- Parameters:
dest
- resulting text, possibly transformed or encodedcontent
- original text contentstart
- index of the first character in contentend
- index of the character following the last character in content
-