Forum: Ferret filter_proc problem with limit

0377ec6fab3880beb5da3dde78af5418?d=identicon&s=25 Henrik Zagerholm (cubiq)
on 2008-07-01 14:43
(Received via mailing list)
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
0377ec6fab3880beb5da3dde78af5418?d=identicon&s=25 Henrik Zagerholm (cubiq)
on 2008-07-04 11:58
(Received via mailing list)
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:
This topic is locked and can not be replied to.