On Wed, May 09, 2007 at 12:59:44PM +0200, Rob Lee wrote: > Hi, > > I'm using acts_as_ferret in my rails application and I'd like to use > more_like_this to retrieve some 'similar' item suggestions. I have a > class 'items' which has a status field and I need to retrieve items that > only have one of the two possible statuses. > > Looking at the more_like_this method indicates it supports an > :append_to_query option that allows you to specify a proc that will > modify the query object before the query is 'run'. This would seem to > allow me to specify extra conditions to the query (such as > +status:live). > > Item.more_like_this(:field_names => [:title, :description, :status], > :append_to_query => Proc .... ) > > It's a little unclear exactly what the query object is and there seem to > be no examples I can find outlining how to use this functionality, does > anybody have an example they could contribute ?
I don't have an exampla at hand, but maybe I can help anyway. The Proc parameter is a BooleanQuery instance. You can add your own conditions to this by adding your own Query to this: query.add_query(Ferret::Search::TermQuery.new(:status, 'live'), :must) 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 _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

