Interface MatchesIterator
-
- All Known Implementing Classes:
FilterMatchesIterator
public interface MatchesIteratorAn iterator over match positions (and optionally offsets) for a single document and fieldTo iterate over the matches, call
next()until it returnsfalse, retrieving positions and/or offsets after each call. You should not call the position or offset methods beforenext()has been called, or afternext()has returnedfalse.Matches from some queries may span multiple positions. You can retrieve the positions of individual matching terms on the current match by calling
getSubMatches().Matches are ordered by start position, and then by end position. Match intervals may overlap.
- See Also:
Weight.matches(LeafReaderContext, int)- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intendOffset()The ending offset of the current match, or-1if offsets are not availableintendPosition()The end position of the current match, or-1if positions are not availableQuerygetQuery()Returns the Query causing the current matchMatchesIteratorgetSubMatches()Returns a MatchesIterator that iterates over the positions and offsets of individual terms within the current matchbooleannext()Advance the iterator to the next match positionintstartOffset()The starting offset of the current match, or-1if offsets are not availableintstartPosition()The start position of the current match, or-1if positions are not available
-
-
-
Method Detail
-
next
boolean next() throws IOExceptionAdvance the iterator to the next match position- Returns:
trueif matches have not been exhausted- Throws:
IOException
-
startPosition
int startPosition()
The start position of the current match, or-1if positions are not availableShould only be called after
next()has returnedtrue
-
endPosition
int endPosition()
The end position of the current match, or-1if positions are not availableShould only be called after
next()has returnedtrue
-
startOffset
int startOffset() throws IOExceptionThe starting offset of the current match, or-1if offsets are not availableShould only be called after
next()has returnedtrue- Throws:
IOException
-
endOffset
int endOffset() throws IOExceptionThe ending offset of the current match, or-1if offsets are not availableShould only be called after
next()has returnedtrue- Throws:
IOException
-
getSubMatches
MatchesIterator getSubMatches() throws IOException
Returns a MatchesIterator that iterates over the positions and offsets of individual terms within the current matchReturns
nullif there are no submatches (ie the current iterator is at the leaf level)Should only be called after
next()has returnedtrue- Throws:
IOException
-
getQuery
Query getQuery()
Returns the Query causing the current matchIf this
MatchesIteratorhas been returned from agetSubMatches()call, then returns aTermQueryequivalent to the current matchShould only be called after
next()has returnedtrue
-
-