public class WeightedHighlighter extends DefaultHighlighter
WeightedHighlighter
implements a highlighter that weights the
fragments based on the proximity of the highlighted terms to each other. The
returned fragments are not necessarily in sequence as the text occurs in the
content.DEFAULT_MAXFRAGMENTS, DEFAULT_SURROUND, END_EXCERPT, END_FRAGMENT_SEPARATOR, END_HIGHLIGHT, START_EXCERPT, START_FRAGMENT_SEPARATOR, START_HIGHLIGHT
Modifier | Constructor and Description |
---|---|
protected |
WeightedHighlighter() |
Modifier and Type | Method and Description |
---|---|
static String |
highlight(org.apache.lucene.index.TermPositionVector tvec,
Set<org.apache.lucene.index.Term[]> queryTerms,
String text,
int maxFragments,
int surround) |
static String |
highlight(org.apache.lucene.index.TermPositionVector tvec,
Set<org.apache.lucene.index.Term[]> queryTerms,
String text,
String excerptStart,
String excerptEnd,
String fragmentStart,
String fragmentEnd,
String hlStart,
String hlEnd,
int maxFragments,
int surround) |
protected String |
mergeFragments(org.apache.lucene.index.TermVectorOffsetInfo[] offsets,
String text,
String excerptStart,
String excerptEnd,
String fragmentStart,
String fragmentEnd,
String hlStart,
String hlEnd,
int maxFragments,
int surround) |
createDefaultExcerpt, doHighlight, escape
public static String highlight(org.apache.lucene.index.TermPositionVector tvec, Set<org.apache.lucene.index.Term[]> queryTerms, String text, String excerptStart, String excerptEnd, String fragmentStart, String fragmentEnd, String hlStart, String hlEnd, int maxFragments, int surround) throws IOException
tvec
- the term position vector for this hitqueryTerms
- the query terms.text
- the original text that was used to create the
tokens.excerptStart
- this string is prepended to the excerptexcerptEnd
- this string is appended to the excerptfragmentStart
- this string is prepended to every fragmentfragmentEnd
- this string is appended to the end of every
fragment.hlStart
- the string used to prepend a highlighted token, for
example "<b>"
hlEnd
- the string used to append a highlighted token, for
example "</b>"
maxFragments
- the maximum number of fragmentssurround
- the maximum number of chars surrounding a
highlighted tokenIOException
public static String highlight(org.apache.lucene.index.TermPositionVector tvec, Set<org.apache.lucene.index.Term[]> queryTerms, String text, int maxFragments, int surround) throws IOException
tvec
- the term position vector for this hitqueryTerms
- the query terms.text
- the original text that was used to create the tokens.maxFragments
- the maximum number of fragmentssurround
- the maximum number of chars surrounding a highlighted
tokenIOException
protected String mergeFragments(org.apache.lucene.index.TermVectorOffsetInfo[] offsets, String text, String excerptStart, String excerptEnd, String fragmentStart, String fragmentEnd, String hlStart, String hlEnd, int maxFragments, int surround) throws IOException
mergeFragments
in class DefaultHighlighter
IOException
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.