Ferret fuzzy matches

Hi guys,

Is there some way of getting ferret matches string, when i do a fuzzy
search?

The scenario is this:

  1. The user search for ‘show’
  2. Nothing was found
  3. So I do a fuzzy search, passing ‘show~’
  4. It gives me somes results, most of all was matched with ‘showcase’
  5. So I want to tell the user that: Nothing was found with ‘show’,
    didn’t you mean ‘showcase’?

So, how do i get the ferret matches string, that was ‘showcase’ in that
scenario?

Thanks in advance,
José Valim

I’ve found out how to do that:

You have a class ‘Class’ with acts_as_ferret, so do that:

queryObj = Class.aff_index.ferret_index.process_query(@query_string)
searchObj = Class.aaf_index.ferret_index.searcher

query_results = queryObj.terms(searchObj).collect! {|item| item[:text]
}.uniq

query_results.is_a?(Array) => true

On Tue, Sep 25, 2007 at 09:06:13PM +0200, José Valim wrote:

I’ve found out how to do that:

You have a class ‘Class’ with acts_as_ferret, so do that:

queryObj = Class.aff_index.ferret_index.process_query(@query_string)
searchObj = Class.aaf_index.ferret_index.searcher

query_results = queryObj.terms(searchObj).collect! {|item| item[:text]
}.uniq

right, however I doubt this kind of direct access to Ferret’s searcher
will
work with aaf’s DRb server.

You should add a method like ‘matching_terms(query_string)’ to aaf’s
LocalIndex class to encapsulate above code, so you can call it across
the DRb connection.

Cheers,
Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs