Documentation of 'org.apache.lucene.search.FuzzyQuery' Java class
FuzzyQuery
org.apache.lucene.search

Class FuzzyQuery

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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
    • Constructor Detail

      • FuzzyQuery

        public FuzzyQuery(Term term,
                          float minimumSimilarity,
                          int prefixLength)
                   throws java.lang.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:
        java.lang.IllegalArgumentException - if minimumSimilarity is >= 1 or < 0 or if prefixLength < 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.
      • rewrite

        public Query rewrite(IndexReader reader)
                      throws java.io.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:
        java.io.IOException
      • toString

        public java.lang.String toString(java.lang.String field)
        Description copied from class: MultiTermQuery
        Prints a user-readable version of this query.
        Overrides:
        toString in class MultiTermQuery

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.