Package org.apache.lucene.search

## Class SloppyPhraseMatcher

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

-     public final class SloppyPhraseMatcher
      extends PhraseMatcher

  Find all slop-valid position-combinations (matches) encountered while traversing/hopping the PhrasePositions.
  The sloppy frequency contribution of a match depends on the distance:
  - highest freq for distance=0 (exact match).
  - freq gets lower as distance gets higher.
  Example: for query "a b"~2, a document "x a b a y" can be matched twice: once for "a b" (distance=0), and once for "b a" (distance=2).
  Possibly not all valid combinations are encountered, because for efficiency we always propagate the least PhrasePosition. This allows to base on PriorityQueue and move forward faster. As result, for example, document "a b c b a" would score differently for queries "a b c"~4 and "c b a"~4, although they really are equivalent. Similarly, for doc "a b c b a f g", query "c b"~2 would get same score as "g f"~2, although "c b"~2 could be matched twice. We may want to fix this in the future (currently not, for performance reasons).
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SloppyPhraseMatcher​(PhraseQuery.PostingsAndFreq[] postings, int slop, ScoreMode scoreMode, Similarity.SimScorer scorer, float matchCost, boolean captureLeadMatch)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `endOffset()` |
    `int` | `endPosition()` |
    `boolean` | `nextMatch()` | Find the next match on the current document, returning `false` if there are none.
    `void` | `reset()` | Called after `PhraseMatcher.approximation()` has been advanced
    `int` | `startOffset()` |
    `int` | `startPosition()` |

    - ### Methods inherited from class org.apache.lucene.search.PhraseMatcher

      `getMatchCost`

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

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

- - ### Constructor Detail

    - #### SloppyPhraseMatcher

          public SloppyPhraseMatcher​(PhraseQuery.PostingsAndFreq[] postings,
                                     int slop,
                                     ScoreMode scoreMode,
                                     Similarity.SimScorer scorer,
                                     float matchCost,
                                     boolean captureLeadMatch)

  - ### Method Detail

    - #### reset

          public void reset()
                     throws IOException

      Description copied from class: `PhraseMatcher`
      Called after `PhraseMatcher.approximation()` has been advanced
      Specified by:
        `reset` in class `PhraseMatcher`
      Throws:
        `IOException`

    - #### nextMatch

          public boolean nextMatch()
                            throws IOException

      Description copied from class: `PhraseMatcher`
      Find the next match on the current document, returning `false` if there are none.
      Specified by:
        `nextMatch` in class `PhraseMatcher`
      Throws:
        `IOException`

    - #### startPosition

          public int startPosition()

    - #### endPosition

          public int endPosition()

    - #### startOffset

          public int startOffset()
                          throws IOException

      Throws:
        `IOException`

    - #### endOffset

          public int endOffset()
                        throws IOException

      Throws:
        `IOException`