org.apache.lucene.sandbox.queries

## Class SlowFuzzyQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.search.MultiTermQuery
    - - org.apache.lucene.sandbox.queries.SlowFuzzyQuery

- Deprecated.
  Use `FuzzyQuery` instead.

      @Deprecated
      public class SlowFuzzyQuery
      extends MultiTermQuery

  Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

  Note that, unlike `FuzzyQuery`, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.search.MultiTermQuery

      `MultiTermQuery.RewriteMethod, MultiTermQuery.TopTermsBlendedFreqScoringRewrite, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `defaultMaxExpansions` Deprecated.
    `static float` | `defaultMinSimilarity` Deprecated.
    `static int` | `defaultPrefixLength` Deprecated.
    `protected Term` | `term` Deprecated.

    - ### Fields inherited from class org.apache.lucene.search.MultiTermQuery

      `CONSTANT_SCORE_BOOLEAN_REWRITE, CONSTANT_SCORE_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_REWRITE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SlowFuzzyQuery(Term term)` Deprecated. Calls `SlowFuzzyQuery(term, defaultMinSimilarity, 0, defaultMaxExpansions)`.
    `SlowFuzzyQuery(Term term, float minimumSimilarity)` Deprecated. Calls `SlowFuzzyQuery(term, minimumSimilarity, 0, defaultMaxExpansions)`.
    `SlowFuzzyQuery(Term term, float minimumSimilarity, int prefixLength)` Deprecated. Calls `SlowFuzzyQuery(term, minimumSimilarity, prefixLength, defaultMaxExpansions)`.
    `SlowFuzzyQuery(Term term, float minimumSimilarity, int prefixLength, int maxExpansions)` Deprecated. Create a new SlowFuzzyQuery that will match terms with a similarity of at least `minimumSimilarity` to `term`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)` Deprecated.
    `float` | `getMinSimilarity()` Deprecated. Returns the minimum similarity that is required for this query to match.
    `int` | `getPrefixLength()` Deprecated. Returns the non-fuzzy prefix length.
    `Term` | `getTerm()` Deprecated. Returns the pattern term.
    `protected TermsEnum` | `getTermsEnum(Terms terms, AttributeSource atts)` Deprecated.
    `int` | `hashCode()` Deprecated.
    `String` | `toString(String field)` Deprecated.

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

      `getField, getRewriteMethod, getTermsEnum, rewrite, setRewriteMethod`

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

      `classHash, createWeight, sameClassAs, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### defaultMinSimilarity

          public static final float defaultMinSimilarity

      Deprecated.
      See Also:
        Constant Field Values

    - #### defaultPrefixLength

          public static final int defaultPrefixLength

      Deprecated.
      See Also:
        Constant Field Values

    - #### defaultMaxExpansions

          public static final int defaultMaxExpansions

      Deprecated.
      See Also:
        Constant Field Values

    - #### term

          protected Term term

      Deprecated.

  - ### Constructor Detail

    - #### SlowFuzzyQuery

          public SlowFuzzyQuery(Term term,
                                float minimumSimilarity,
                                int prefixLength,
                                int maxExpansions)

      Deprecated.
      Create a new SlowFuzzyQuery that will match terms with a similarity of at least `minimumSimilarity` to `term`. If a `prefixLength` > 0 is specified, a common prefix of that length is also required.
      Parameters:
        `term` - the term to search for
        `minimumSimilarity` - a value between 0 and 1 to set the required similarity between the query term and the matching terms. For example, for a `minimumSimilarity` of `0.5` a term of the same length as the query term is considered similar to the query term if the edit distance between both terms is less than `length(term)*0.5`

        Alternatively, if `minimumSimilarity` is >= 1f, it is interpreted as a pure Levenshtein edit distance. For example, a value of `2f` will match all terms within an edit distance of `2` from the query term. Edit distances specified in this way may not be fractional.

        `prefixLength` - length of common (non-fuzzy) prefix
        `maxExpansions` - the maximum number of terms to match. If this number is greater than `BooleanQuery.getMaxClauseCount()` when the query is rewritten, then the maxClauseCount will be used instead.
      Throws:
        `IllegalArgumentException` - if minimumSimilarity is >= 1 or < 0 or if prefixLength < 0

    - #### SlowFuzzyQuery

          public SlowFuzzyQuery(Term term,
                                float minimumSimilarity,
                                int prefixLength)

      Deprecated.
      Calls `SlowFuzzyQuery(term, minimumSimilarity, prefixLength, defaultMaxExpansions)`.

    - #### SlowFuzzyQuery

          public SlowFuzzyQuery(Term term,
                                float minimumSimilarity)

      Deprecated.
      Calls `SlowFuzzyQuery(term, minimumSimilarity, 0, defaultMaxExpansions)`.

    - #### SlowFuzzyQuery

          public SlowFuzzyQuery(Term term)

      Deprecated.
      Calls `SlowFuzzyQuery(term, defaultMinSimilarity, 0, defaultMaxExpansions)`.

  - ### Method Detail

    - #### getMinSimilarity

          public float getMinSimilarity()

      Deprecated.
      Returns the minimum similarity that is required for this query to match.
      Returns:
        float value between 0.0 and 1.0

    - #### getPrefixLength

          public int getPrefixLength()

      Deprecated.
      Returns the non-fuzzy prefix length. This is the number of characters at the start of a term that must be identical (not fuzzy) to the query term if the query is to match that term.

    - #### getTermsEnum

          protected TermsEnum getTermsEnum(Terms terms,
                                           AttributeSource atts)
                                    throws IOException

      Deprecated.
      Specified by:
        `getTermsEnum` in class `MultiTermQuery`
      Throws:
        `IOException`

    - #### getTerm

          public Term getTerm()

      Deprecated.
      Returns the pattern term.

    - #### toString

          public String toString(String field)

      Deprecated.
      Specified by:
        `toString` in class `Query`

    - #### hashCode

          public int hashCode()

      Deprecated.
      Overrides:
        `hashCode` in class `MultiTermQuery`

    - #### equals

          public boolean equals(Object obj)

      Deprecated.
      Overrides:
        `equals` in class `MultiTermQuery`

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