Class Passage
- java.lang.Object
-
- org.apache.lucene.search.uhighlight.Passage
-
public class Passage extends java.lang.Object
Represents a passage (typically a sentence of the document).A passage contains
getNumMatches()
highlights from the query, and the offsets and query terms that correspond with each match.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description Passage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 withgetMatchStarts()
.int[]
getMatchStarts()
Start offsets of the term matches, in increasing order.int[]
getMatchTermFreqsInDoc()
BytesRef[]
getMatchTerms()
BytesRef (term text) of the matches, corresponding withgetMatchStarts()
.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.
-
-
-
Field Detail
-
startOffset
private int startOffset
-
endOffset
private int endOffset
-
score
private float score
-
matchStarts
private int[] matchStarts
-
matchEnds
private int[] matchEnds
-
matchTerms
private BytesRef[] matchTerms
-
matchTermFreqInDoc
private int[] matchTermFreqInDoc
-
numMatches
private int numMatches
-
-
Method Detail
-
addMatch
public void addMatch(int startOffset, int endOffset, BytesRef term, int termFreqInDoc)
-
reset
public void reset()
-
toString
public java.lang.String toString()
For debugging. ex: Passage[0-22]{yin[0-3],yang[4-8],yin[10-13]}score=2.4964213- Overrides:
toString
in classjava.lang.Object
-
getStartOffset
public int getStartOffset()
Start offset of this passage.- Returns:
- start index (inclusive) of the passage in the original content: always >= 0.
-
getEndOffset
public int getEndOffset()
End offset of this passage.- Returns:
- end index (exclusive) of the passage in the original content: always >=
getStartOffset()
-
getLength
public int getLength()
-
getScore
public float getScore()
Passage's score.
-
setScore
public void setScore(float score)
-
getNumMatches
public int getNumMatches()
-
getMatchStarts
public int[] getMatchStarts()
Start offsets of the term matches, in increasing order.Only
getNumMatches()
are valid. Note that these offsets are absolute (not relative togetStartOffset()
).
-
getMatchEnds
public int[] getMatchEnds()
End offsets of the term matches, corresponding withgetMatchStarts()
.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.
-
getMatchTerms
public BytesRef[] getMatchTerms()
BytesRef (term text) of the matches, corresponding withgetMatchStarts()
. 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.
-
getMatchTermFreqsInDoc
public int[] getMatchTermFreqsInDoc()
-
setStartOffset
public void setStartOffset(int startOffset)
-
setEndOffset
public void setEndOffset(int endOffset)
-
-