# Filter\_proc does not work as expected

**URL:** <https://www.ruby-forum.com/t/filter-proc-does-not-work-as-expected/182180>\
**Category:** Ferret\
**Created:** [January 24, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/filter-proc-does-not-work-as-expected/182180 "2010-01-24T12:03:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [January 24, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/filter-proc-does-not-work-as-expected/182180/1 "2010-01-24T12:03:16Z")

</div>

Hi there

Since some days I’m developing a fulltext-search for our Bugzilla  
system. Initial development time was very short but now I’m working on  
some details and it does not work as expected. Basically it’s two  
different problems but most likely related to each other. Attached is a  
complete script which illustrates these two problems. Here some  
excerpts.

Problem 1:  
According to the Ferret API documentation it’s valid to scale the score  
of results in a filter\_proc like this:  
filter\_proc = lambda do |doc\_id, score, searcher|  
age = searcher[doc\_id][:age].to\_i  
1.0/age  
end  
The filter\_proc gets executed but the scale returned is just ignored by  
ferret. Why is this?

Problem 2:  
Why does this search return “0.0” as score for all docs?  
docs = index.search("+matching +age:2", :filter\_proc =\> simple\_proc)  
If I remove the filter\_proc or the “+” before the age it works. The  
simple\_proc just returns true for all input. Why do I loose the score  
here?

For me it looks like this whole filter\_proc stuff is not yet stable or  
maybe I don’t use it as I should. Any ideas?

Thanks a lot,  
Thomas

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [January 24, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/filter-proc-does-not-work-as-expected/182180/2 "2010-01-24T12:04:00Z")

</div>

sorry, attachment got lost. Next try…

Thomas
