Class DefaultPassageFormatter
- java.lang.Object
-
- org.apache.lucene.search.postingshighlight.PassageFormatter
-
- org.apache.lucene.search.postingshighlight.DefaultPassageFormatter
-
public class DefaultPassageFormatter extends PassageFormatter
Creates a formatted snippet from the top passages.The default implementation marks the query terms as bold, and places ellipses between unconnected passages.
-
-
Constructor Summary
Constructors Constructor Description DefaultPassageFormatter()Creates a new DefaultPassageFormatter with the default tags.DefaultPassageFormatter(java.lang.String preTag, java.lang.String postTag, java.lang.String ellipsis, boolean escape)Creates a new DefaultPassageFormatter with custom tags.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(Passage[] passages, java.lang.String content)Formats the toppassagesfromcontentinto a human-readable text snippet.
-
-
-
Constructor Detail
-
DefaultPassageFormatter
public DefaultPassageFormatter()
Creates a new DefaultPassageFormatter with the default tags.
-
DefaultPassageFormatter
public DefaultPassageFormatter(java.lang.String preTag, java.lang.String postTag, java.lang.String ellipsis, boolean escape)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 Detail
-
format
public java.lang.String format(Passage[] passages, java.lang.String content)
Description copied from class:PassageFormatterFormats the toppassagesfromcontentinto a human-readable text snippet.- Specified by:
formatin 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
PostingsHighlighterthat return String, the toString method on the Object returned by this method is used to compute the string.
-
-