Class 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 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
    • Constructor Detail

      • Passage

        public Passage()
    • 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 class java.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)
      • 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 to getStartOffset()).

      • getMatchEnds

        public int[] getMatchEnds()
        End offsets of the term matches, corresponding with 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.

      • getMatchTerms

        public BytesRef[] getMatchTerms()
        BytesRef (term text) of the matches, corresponding with 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.

      • getMatchTermFreqsInDoc

        public int[] getMatchTermFreqsInDoc()
      • setStartOffset

        public void setStartOffset​(int startOffset)
      • setEndOffset

        public void setEndOffset​(int endOffset)