public class DefaultPassageFormatter extends PassageFormatter
The default implementation marks the query terms as bold, and places ellipses between unconnected passages.
Modifier and Type | Field and Description |
---|---|
protected String |
ellipsis
text that will appear between two unconnected passages
|
protected boolean |
escape
true if we should escape for html
|
protected String |
postTag
text that will appear after highlighted terms
|
protected String |
preTag
text that will appear before highlighted terms
|
Constructor and Description |
---|
DefaultPassageFormatter()
Creates a new DefaultPassageFormatter with the default tags.
|
DefaultPassageFormatter(String preTag,
String postTag,
String ellipsis,
boolean escape)
Creates a new DefaultPassageFormatter with custom tags.
|
Modifier and Type | Method and Description |
---|---|
protected void |
append(StringBuilder dest,
String content,
int start,
int end)
Appends original text to the response.
|
String |
format(Passage[] passages,
String content)
Formats the top
passages from content
into a human-readable text snippet. |
protected final String preTag
protected final String postTag
protected final String ellipsis
protected final boolean escape
public DefaultPassageFormatter()
public DefaultPassageFormatter(String preTag, String postTag, String ellipsis, boolean escape)
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-escapedpublic String format(Passage[] passages, String content)
PassageFormatter
passages
from content
into a human-readable text snippet.format
in class PassageFormatter
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.UnifiedHighlighter
that
return String, the toString method on the Object
returned by this method is used to compute the string.protected void append(StringBuilder dest, String content, int start, int end)
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 contentCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.