# Filter\_proc problem with limit

**URL:** <https://www.ruby-forum.com/t/filter-proc-problem-with-limit/141895>\
**Category:** Ferret\
**Created:** [July 1, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/filter-proc-problem-with-limit/141895 "2008-07-01T14:43:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cubiq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b19c9b/32.png) [@cubiq](https://www.ruby-forum.com/u/cubiq)\
**Post date:** [July 1, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/filter-proc-problem-with-limit/141895/1 "2008-07-01T14:43:54Z")

</div>

Hi list,

I have a problem grouping with ferret.

I’m using the filter\_proc from Dave’s book as seen below

results = {}  
group\_by\_proc = lambda do |doc\_id, score, searcher|  
doc = searcher[doc\_id]  
(results[doc[:pk\_file\_id]]||=[]) \<\< doc[:filename] \<\< doc[:path]  
next true  
end

The problem is that if I use this it ignores my limit clause.

I set limit on 10 and I still get 5995 results and it takes several  
seconds.

How come the limit clause is ignored when using a filter\_proc? How can  
I change this behaviour?

term = “wi”

bool1 = Ferret::Search::BooleanQuery.new()  
bool1.add\_query(Ferret::Search::PrefixQuery.new(:filename, “#{term}”))  
bool1.add\_query(Ferret::Search::PrefixQuery.new(:path, “#{term}”))

index.search(bool1, :limit =\> 10, :filter\_proc =\> group\_by\_proc)

puts result.size  
5995

Cheers,  
Henke

---

<div class="post-metadata">

**Author:** ![cubiq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b19c9b/32.png) [@cubiq](https://www.ruby-forum.com/u/cubiq)\
**Post date:** [July 4, 2008, 11:58am UTC](https://www.ruby-forum.com/t/filter-proc-problem-with-limit/141895/2 "2008-07-04T11:58:21Z")

</div>

Has anyone tried this?

I’m I the only one trying to group results from ferret?

Cheers,  
Henke

1 jul 2008 kl. 14.43 skrev Henrik:
