public class Passage
extends java.lang.Object
A passage contains getNumMatches()
highlights from the query,
and the offsets and query terms that correspond with each match.
Modifier and Type | Field and Description |
---|---|
private int |
endOffset |
private int[] |
matchEnds |
private int[] |
matchStarts |
private int[] |
matchTermFreqInDoc |
private BytesRef[] |
matchTerms |
private int |
numMatches |
private float |
score |
private int |
startOffset |
Constructor and Description |
---|
Passage() |
Modifier and Type | Method and Description |
---|---|
void |
addMatch(int startOffset,
int endOffset,
BytesRef term,
int termFreqInDoc) |
int |
getEndOffset()
End offset of this passage.
|
int |
getLength() |
int[] |
getMatchEnds()
End offsets of the term matches, corresponding with
getMatchStarts() . |
int[] |
getMatchStarts()
Start offsets of the term matches, in increasing order.
|
int[] |
getMatchTermFreqsInDoc() |
BytesRef[] |
getMatchTerms()
BytesRef (term text) of the matches, corresponding with
getMatchStarts() . |
int |
getNumMatches()
|
float |
getScore()
Passage's score.
|
int |
getStartOffset()
Start offset of this passage.
|
void |
reset() |
void |
setEndOffset(int endOffset) |
void |
setScore(float score) |
void |
setStartOffset(int startOffset) |
java.lang.String |
toString()
For debugging.
|
private int startOffset
private int endOffset
private float score
private int[] matchStarts
private int[] matchEnds
private BytesRef[] matchTerms
private int[] matchTermFreqInDoc
private int numMatches
public void addMatch(int startOffset, int endOffset, BytesRef term, int termFreqInDoc)
public void reset()
public java.lang.String toString()
toString
in class java.lang.Object
public int getStartOffset()
public int getEndOffset()
getStartOffset()
public int getLength()
public float getScore()
public void setScore(float score)
public int getNumMatches()
public int[] getMatchStarts()
Only getNumMatches()
are valid. Note that these
offsets are absolute (not relative to getStartOffset()
).
public int[] getMatchEnds()
getMatchStarts()
.
Only getNumMatches()
are valid. Note that its possible that an end offset
could exceed beyond the bounds of the passage (getEndOffset()
), if the
Analyzer produced a term which spans a passage boundary.
public BytesRef[] getMatchTerms()
getMatchStarts()
. The primary purpose of this
method is to expose the number of unique terms per passage for use in passage scoring.
The actual term byte content is not well defined by this highlighter, and thus use of it is more subject to
change.
The term might be simply the analyzed term at this position.
Depending on the highlighter's configuration, the match term may be a phrase (instead of a word), and in such
a case might be a series of space-separated analyzed terms.
If the match is from a MultiTermQuery
then the match term may be the toString() of
that query.
Only getNumMatches()
are valid.
public int[] getMatchTermFreqsInDoc()
public void setStartOffset(int startOffset)
public void setEndOffset(int endOffset)