Fuzzy-ness to searches


#1

Hi. I didn’t notice if topic has already been discussed, but I was
wondering if there was a way to make ferret match only part of a search
term. My initial thought was some sort of filter, but I’m unsure of
where to begin.

An example in the comments of the acts_as_ferret tutorial at RailsEnvy
(http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial) suggests:
To return the widest possible array you’d make everything OR’d and
Fuzzy.


@query = params[:search].split(” “).collect{|term| term + ”~”}.join(” OR
“)

However, the example appears only to work where there are multiple
search terms separated by a space like “Dark Star” => “Dark~ OR Star~”.

Currently, in my basic rails app, ferret will only return results if the
search term exactly matches what is stored in the DB.

Example.

A search for “MCF” does not match “MCF-7”, but a search for “MCF-7” will
exactly match the entries with the name “MCF-7” as expected.

Is there a way to get this partial matching behavior with ferret?

Thanks,

Chase


#2

I have, however, noticed that this partial recognition works for longer
words like colo~ for colon, but not for smaller words as I mentioned
previously.

-chase