On Sun, 2008-01-06 at 19:16 +0100, Lars Heese wrote:
> Hello,
> 
> does anybody know how to implement a "Did you mean ...?" like Google
> with act_as_ferret?
> 
> I think this is a possible way:

Hi Lars,

I did a similar thing in a project except the only things I wanted to
suggest were pre-defined tag names in a table.  So I just indexed that
and did a fuzzy search on it.

But anyway, you can enumerate all the terms in an index for a given
field using the terms method of the IndexReader instance for the index:

http://ferret.davebalmain.com/api/classes/Ferret/Index/TermEnum.html

Then generate your other index from that.  You can store the words
directly in the Ferret index to avoid the unnecessary overhead of an SQL
lookup.

With a small list of terms, I'm not sure what the overhead of Ferret
would be here though.  Might be worth experimenting with some
alternatives, like maybe generating an index yourself as an array
directly in Ruby.  See the Text library for Metaphone and Soundex
algorithms:

http://text.rubyforge.org/

Ferret will probably be best though tbh.

John.
-- 
http://www.brightbox.co.uk - UK Ruby on Rails hosting

_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to