PhraseMatcher (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search, class: PhraseMatcher

Package org.apache.lucene.search

# Class PhraseMatcher

java.lang.Object
org.apache.lucene.search.PhraseMatcher

Direct Known Subclasses:
  `ExactPhraseMatcher`, `SloppyPhraseMatcher`

public abstract class PhraseMatcher extends Object
Base class for exact and sloppy phrase matching

To find matches on a document, first advance `approximation()` to the relevant document, then call `resetPositions()`. Clients can then call `nextMatch()` to iterate over the matches

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getMatchCost()`
  An estimate of the average cost of finding all matches on a document
  `abstract boolean`
  `nextMatch()`
  Find the next match on the current document, returning `false` if there are none.
  `abstract void`
  `resetPositions()`
  Called after `approximation()` has been advanced to load positions for matching.

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

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

- ## Method Details

  - ### resetPositions

    public abstract void resetPositions() throws IOException
    Called after `approximation()` has been advanced to load positions for matching.
    Throws:
      `IOException`

  - ### nextMatch

    public abstract boolean nextMatch() throws IOException
    Find the next match on the current document, returning `false` if there are none.
    Throws:
      `IOException`

  - ### getMatchCost

    public float getMatchCost()
    An estimate of the average cost of finding all matches on a document
    See Also:
      - `TwoPhaseIterator.matchCost()`