org.apache.lucene.search.uhighlight

## Class Passage

- java.lang.Object
- - org.apache.lucene.search.uhighlight.Passage

-     public class Passage
      extends 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.

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Passage()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMatch(int startOffset, int endOffset, BytesRef term)`
    `int` | `getEndOffset()` End offset of this passage.
    `int[]` | `getMatchEnds()` End offsets of the term matches, corresponding with `getMatchStarts()`.
    `int[]` | `getMatchStarts()` Start offsets of the term matches, in increasing order.
    `BytesRef[]` | `getMatchTerms()` BytesRef (term text) of the matches, corresponding with `getMatchStarts()`.
    `int` | `getNumMatches()` Number of term matches available in `getMatchStarts()`, `getMatchEnds()`, `getMatchTerms()`
    `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)`
    `void` | `sort()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Passage

          public Passage()

  - ### Method Detail

    - #### addMatch

          public void addMatch(int startOffset,
                               int endOffset,
                               BytesRef term)

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

    - #### sort

          public void sort()

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

    - #### reset

          public void reset()

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

    - #### 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()`

    - #### getScore

          public float getScore()

      Passage's score.

    - #### getNumMatches

          public int getNumMatches()

      Number of term matches available in `getMatchStarts()`, `getMatchEnds()`, `getMatchTerms()`

    - #### 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()`.

      Only `getNumMatches()` are valid.

    - #### setStartOffset

          public void setStartOffset(int startOffset)

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

    - #### setEndOffset

          public void setEndOffset(int endOffset)

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

    - #### setScore

          public void setScore(float score)

      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.