Class: Ferret::Search::FuzzyQuery

Inherits:
Object
  • Object
show all
Defined in:
ext/r_search.c

Overview

Summary

FuzzyQuery uses the Levenshtein distance formula for measuring the similarity between two terms. For example, weak and week have one letter difference and they are four characters long so the simlarity is 75% or 0.75. You can use this query to match terms that are very close to the search term.

Example

FuzzyQuery can be quite useful for find documents that wouldn’t normally be found because of typos.

FuzzyQuery.new(:field, "google",
               :min_similarity => 0.6,
               :prefix_length => 2)
# matches => "gogle", "goggle", "googol", "googel"