Discussion:
:multi search (again)
Jens Krämer
2008-10-28 19:10:41 UTC
Permalink
Hi!

First of all you should decide which exact behaviour you want - do you
want your search results contain different model objects like tracks,
releases and artists?

Or do you always want to find a certain type of model object, but also
find it when somebody searches for a word contained in a property of
some related record (like, say, find releases of an artist when
searching for his name)?

Or a combination of both, so that searching for an artists name will
return all his releases and the artist record itself?

First of all, every single model you expect in your result set has to
call acts_as_ferret. Then, for every record, index all the information
you think is useful, like you intend to do with the release names in
your artist model. The artist_releases method has to return a string
containing the value you want to index - so something like

self.releases.map(&:name).join(' ')

should work.

Watch the logs to see what values actually get indexed.

Cheers,
Jens
apologies for the poor form, but I've modified the below
def artist_releases
return "#{self.release_artist.release.name}"
end
to say this
def artist_releases
self.releases
end
this works, in as much as self.releases will return an array of releases
by an artists, because of the HABTM relationship defined previously.
However, I'm still confused as to how this then translates into the
ability to search for "an artist" and to be returned related releases by
said artist.
If anyone can help, or offer some pointers on this, I'd be quite
appreciative.
thanks
--
Posted via http://www.ruby-forum.com/.
Loading...