Fuzzy search question

Hi,

I’ve got a question about FuzzyQueries. Say I’m doing a search for
people by name, and I want to allow fuzzy results if there aren’t
enough hits with a regular query. This is easy enough; just redo the
search with the fuzzy query if original_results.total_hits is less
than some threshold. However, I would like the exact-match results to
have a higher score (show up as the first results) than the fuzzy-
match results. One really clumsy way of doing this is to do the two
searches and concatenate the results in order into a new set of
results (I’m using ActsAsFerret, so I’d be doing some surgery on
ActsAsFerret::SearchResults that gets pretty fragile with pagination).

Is there an easier way to have a FuzzyQuery return the exact hits
first? It looks like the score is the same regardless of the fuzziness
of a specific term match.

thanks!

Hi,

didn’t try this out but what about doing an OR query and have the
non-fuzzy part of the query boosted?

name:smith^10 OR name:smith~0.4

Jens

On Sun, Jan 20, 2008 at 08:21:55PM -0500, Noah M. Daniels wrote:

results (I’m using ActsAsFerret, so I’d be doing some surgery on
http://rubyforge.org/mailman/listinfo/ferret-talk


Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database

I know this is the Ferret forum, but you can also do this very easily
with n-grams. I’ve created a simple fuzzy autocomplete in Rails where
better matches rise to the top:

Enjoy.

Noah Daniels wrote:

than some threshold. However, I would like the exact-match results to
have a higher score (show up as the first results) than the fuzzy-
match results. One really clumsy way of doing this is to do the two