FuzzyQuery (Lucene 2.4.1 API)
Keywords: org.apache.lucene.search.FuzzyQuery class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.search
Class FuzzyQuery

    java.lang.Object
      org.apache.lucene.search.Query
          org.apache.lucene.search.MultiTermQuery
              org.apache.lucene.search.FuzzyQuery

All Implemented Interfaces:
  Serializable, Cloneable

    public class FuzzyQuery

extends MultiTermQuery

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

See Also:
  Serialized Form

Nested Class Summary
`protected static class` | `FuzzyQuery.ScoreTerm`
`protected static class` | `FuzzyQuery.ScoreTermQueue`

Field Summary
`static float` | `defaultMinSimilarity`
`static int` | `defaultPrefixLength`

Constructor Summary
`FuzzyQuery(Term term)` Calls `FuzzyQuery(term, 0.5f, 0)`.
`FuzzyQuery(Term term, float minimumSimilarity)` Calls `FuzzyQuery(term, minimumSimilarity, 0)`.
`FuzzyQuery(Term term, float minimumSimilarity, int prefixLength)` Create a new FuzzyQuery that will match terms with a similarity of at least `minimumSimilarity` to `term`.

Method Summary
`boolean` | `equals(Object o)`
`protected FilteredTermEnum` | `getEnum(IndexReader reader)` Construct the enumeration to be used, expanding the pattern term.
`float` | `getMinSimilarity()` Returns the minimum similarity that is required for this query to match.
`int` | `getPrefixLength()` Returns the non-fuzzy prefix length.
`int` | `hashCode()`
`Query` | `rewrite(IndexReader reader)` Expert: called to re-write queries into primitive queries.
`String` | `toString(String field)` Prints a user-readable version of this query.

Methods inherited from class org.apache.lucene.search.MultiTermQuery
`getTerm`

Methods inherited from class org.apache.lucene.search.Query
`clone, combine, createWeight, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### defaultMinSimilarity

    public static final float defaultMinSimilarity

See Also:
  Constant Field Values

### defaultPrefixLength

    public static final int defaultPrefixLength

See Also:
  Constant Field Values

Constructor Detail

### FuzzyQuery

    public FuzzyQuery(Term term,
                      float minimumSimilarity,
                      int prefixLength)
               throws IllegalArgumentException

  Create a new FuzzyQuery 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`
    `prefixLength` - length of common (non-fuzzy) prefix
  Throws:
    `IllegalArgumentException` - if minimumSimilarity is >= 1 or < 0 or if prefixLength < 0

### FuzzyQuery

    public FuzzyQuery(Term term,
                      float minimumSimilarity)
               throws IllegalArgumentException

  Calls `FuzzyQuery(term, minimumSimilarity, 0)`.

  Throws:
    `IllegalArgumentException`

### FuzzyQuery

    public FuzzyQuery(Term term)

  Calls `FuzzyQuery(term, 0.5f, 0)`.

Method Detail

### getMinSimilarity

    public float getMinSimilarity()

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

  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.

### getEnum

    protected FilteredTermEnum getEnum(IndexReader reader)
                                throws IOException

  Description copied from class: `MultiTermQuery`
  Construct the enumeration to be used, expanding the pattern term.

  Specified by:
    `getEnum` in class `MultiTermQuery`
  Throws:
    `IOException`

### rewrite

    public Query rewrite(IndexReader reader)
                  throws IOException

  Description copied from class: `Query`
  Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

  Overrides:
    `rewrite` in class `MultiTermQuery`
  Throws:
    `IOException`

### toString

    public String toString(String field)

  Description copied from class: `MultiTermQuery`
  Prints a user-readable version of this query.

  Overrides:
    `toString` in class `MultiTermQuery`

### equals

    public boolean equals(Object o)

  Overrides:
    `equals` in class `MultiTermQuery`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `MultiTermQuery`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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