Forums » Ferret » Multiple terms accross multipl fields and associated tables

Multiple terms accross multipl fields and associated tables
Posted by Wolfgang Borgon (wborgon)
on 02.07.2006 22:29
I'm looking for a good way to search a few fields accross multiple 
asociated tables (i.e. find 'friends and family' accross Photo.name, 
Photo.description, and Tags.name where Photo has_many tags). And, 
ideally there's a competent query analyzer/parser.

I've expirimented with constructing my own SQL using ... LIKE %term1% 
... etc, but the performance is poor -- queries take seconds or more 
depending on the number of terms.

Will acts_as_ferret work for me? Any recommendations?
Thanks!
Re: Multiple terms accross multipl fields and associated tables
Posted by Jan Prill (Guest)
on 03.07.2006 09:51
Hi Wolfgang,

at least ferret will work perfectly well for you.

Let your photo-model 'acts_as_ferret' and make acts_as_ferret index a 
method
named eg 'all_tags' which returns a comma (or tab or whatever) seperated
string of your tags on this photo. Now you'll be able to constructs a 
query
as described in the rdocs of the QueryParser of ferret that includes 
your
tags and should be very performant.

Cheers,
Jan
Re: Multiple terms accross multipl fields and associated tables
Posted by Jan Prill (Guest)
on 03.07.2006 12:00
Hi Wolfgang,

at least ferret will work perfectly well for you.

Let your photo-model 'acts_as_ferret' and make acts_as_ferret index a 
method
named eg 'all_tags' which returns a comma (or tab or whatever) seperated
string of your tags on this photo. Now you'll be able to constructs a 
query
as described in the rdocs of the QueryParser of ferret that includes 
your
tags and should be very performant.

Cheers,
Jan
Re: Multiple terms accross multipl fields and associated tables
Posted by Wolfgang Borgon (wborgon)
on 04.07.2006 07:12
Jan,
Thanks a lot...I saw a blog posting recommending the same thing after I 
posted... it works like a charm. I like it and far faster and 
confidence-inspiring than mysql LIKE.

For anyone else that sees this, the blog post I saw is:
http://olivier.liquid-concept.ch/articles/2006/04/17/add-tags-in-a-ferret-index

W



Jan Prill wrote:
> Hi Wolfgang,
> 
> at least ferret will work perfectly well for you.
> 
> Let your photo-model 'acts_as_ferret' and make acts_as_ferret index a 
> method
> named eg 'all_tags' which returns a comma (or tab or whatever) seperated
> string of your tags on this photo. Now you'll be able to constructs a 
> query
> as described in the rdocs of the QueryParser of ferret that includes 
> your
> tags and should be very performant.
> 
> Cheers,
> Jan