On Thu, Sep 07, 2006 at 04:58:08PM +0200, Caspar wrote:
> Hello, I need to be able to count the occurences of certain terms in the 
> reults.
> Currently my setup is Ferret 0.10.1 aaf bleeding edge.
> 
> results = VoObject.find_by_contents(query,:offset=>page, :limit=> 
> 20,:sort => sort_fields)
> 
> I use results.total_hits for pagination. This all works really nicely. 
> However i need to be able to know how many occurences of certain 
> predefined terms occur in each result set. So in the animals fields 
> there can be "mouse", "cat", "fish".
> A perfect sollution would be to have the results set has some extra 
> attributes like results.cat_hits (that would be amazing) In reality 
> there needs to be counts for 5 different fields.
> 
> So is this something that ferret can do easily?
> How do i get ferret and aaf to produce this data for each search result?
> What should i go and investigate?

I'd first try to just issue a seperate query for each of your special
terms (ANDed with the original query), and take it's result count.

Ideally you wouldn't use find_by_contents for this (because it fetches
results from the db, which you don't want here), but use something like

VoObject.ferret_index.search(query + " AND cat",...).total_hits


Jens

-- 
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       [EMAIL PROTECTED]
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to