Okay firstly the sponsored listings are what we call the paid for 
premier style of listing in our site. In the listings db table there are 
a few fields that describe the sponsored feature. Ferret is used to 
index one of them which is a boolean called sponsored which simple 
defines a listing as being sponsored. Ferret doesn't know (as far as I'm 
aware..) how to compare booleans so you need this declaration somewhere 
in your model. Which tells ferret how to handle boolean comparrisons.

def false.<=>(o)  o ? -1 : 0 end
def true.<=>(o)  !o ? 1 : 0 end

Then it's just a case of defining your sort fields and then using them 
in your ferret search like so.

sort_fields = []
sort_fields << Ferret::Search::SortField.new(:sponsored, :reverse => 
:true)
sort_fields << Ferret::Search::SortField::SCORE


results = VoObject.find_by_contents(query,:sort 
=>sort_fields,:offset=>page,:limit => RESULTS_PER_PAGE)

I'm a rank amateur when it comes to ruby/rails/ferret so please don't 
take this as the right/best way to do it, but it works for me.
Hope this helps.
Regards
Caspar

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to