# Filter\_proc under acts\_as\_ferret

**URL:** <https://www.ruby-forum.com/t/filter-proc-under-acts-as-ferret/135664>\
**Category:** Ferret\
**Created:** [April 23, 2008, 11:27pm UTC](https://www.ruby-forum.com/t/filter-proc-under-acts-as-ferret/135664 "2008-04-23T23:27:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sseung](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sseung](https://www.ruby-forum.com/u/sseung)\
**Post date:** [April 23, 2008, 11:27pm UTC](https://www.ruby-forum.com/t/filter-proc-under-acts-as-ferret/135664/1 "2008-04-23T23:27:15Z")

</div>

Hi,  
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”)  
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,

-Spencer
