Filter_proc under acts_as_ferret

I’m having a problem with acts_as_ferret and the :filter_proc option
that gets passed to ferret::search. Let me preface this with being a
ferret/AaF noob.

The situation:
I am trying to extend the search functionality of a website that has
already been built. I understand that ferret isn’t (or doesn’t seem to
be) designed for numerical value searches, but at the moment it seems
that it would be easier to try to get it to work rather than completely
rebuild the search. We have a number of products, and they have
numerical values associated to certain attributes. For example, a pair
of shoes might have a trendiness value of 50. If someone searched for
trendiness:50 then those shoes would show up. But we want it to show up
even if trendiness:55 is the query. I figured doing a range search would
take care of that (Can aaf do ranged queries?)
The problem is that if a user searches for trendiness:55 and there are
two hits, one a pair of shoes with trendiness:50 and another with
trendiness:45, The first shoes should have a higher score. I figure that
passing a search a :filter_proc that looks at the searcher object,
calculates the distance between search query and value and then return a
float to weight the score would do the trick. I just can’t seem to get
that to work. Ignoring the rangedQuery part, The following lines output
the same results with the same scores:

Product.find_id_with_contents(“shoes”, :filter_proc => lambda
{|doc_id,score, searcher| return 0.5}

Shouldn’t the 2nd version have halved the resulting ferret_scores of
each result?

thanks for the time,


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