Paul Wright
2006-Aug-08 11:32 UTC
[Ferret-talk] acts_as_ferret to search partial phrases and fuzzy
Hi All, I was wondering if anyone had experience of extending AAF plugin for Rails to implement a broader query ? The documentation and the demo provided on the http://projects.jkraemer.net/acts_as_ferret/ wiki seems to only match full text queries, or partial when using a * wildcard. Ideally, I am trying to acheive something similar to the following (pseudo code): def search @query = params[:query] || '''' unless @query.blank? @results = Content.find_by_contents @query if @results.empty? @results = Content.partial_word_search @query if @results.empty? @results = Content.fuzzy_word_search @query end end end end I realise I could probably achieve something like this by changing http://wiki.rubyonrails.com/rails/pages/HowToIntegrateFerretWithRails to meet my needs, but I quite like the indexing elegance provided with AAF, and don''t want to have to reinvent the wheel. If anyone has experience or pointers that would be great! Apologies for posting on the ferret list for a rails-ish problem, but searching the archives seemed to show most of the questions end up here! Thank, Paul -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Aug-10 08:37 UTC
[Ferret-talk] acts_as_ferret to search partial phrases and fuzzy
Hi Paul! By default, aaf uses the stock Ferret QueryParser to parse queries handed to find_by_contents. You have the full power of the Ferret Query Language, including fuzzy search and friends. However, if you give find_by_contents a Query object, this query will be taken as is. So the easiest way to use aaf with custom queries would be to build those queries outside aaf and use them with find_by_contents. Does this already solve your problem ? Jens On Tue, Aug 08, 2006 at 01:32:00PM +0200, Paul Wright wrote:> Hi All, > > I was wondering if anyone had experience of extending AAF plugin for > Rails to implement a broader query ? > > The documentation and the demo provided on the > http://projects.jkraemer.net/acts_as_ferret/ wiki seems to only match > full text queries, or partial when using a * wildcard. > > Ideally, I am trying to acheive something similar to the following > (pseudo code): > > def search > @query = params[:query] || '''' > unless @query.blank? > @results = Content.find_by_contents @query > if @results.empty? > @results = Content.partial_word_search @query > if @results.empty? > @results = Content.fuzzy_word_search @query > end > end > end > end > > I realise I could probably achieve something like this by changing > http://wiki.rubyonrails.com/rails/pages/HowToIntegrateFerretWithRails to > meet my needs, but I quite like the indexing elegance provided with AAF, > and don''t want to have to reinvent the wheel. > > If anyone has experience or pointers that would be great! > > Apologies for posting on the ferret list for a rails-ish problem, but > searching the archives seemed to show most of the questions end up here! > > Thank, > Paul > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66