logo       

Re: Search Multiple Models: msg#00049

lang.ruby.ferret.general

Subject: Re: Search Multiple Models

Jens,

> In theory there's the multi_search method for exactly your scenario:
> results = Article.multi_search(query, [ Blog, MusicTrack, MediaFile ])
> the big upside of this is that you get comparable scores and therefore a
> reasonable sorting by relevance. the downside is that it does a find on
> each id just as you do above.

I'm tried the following, which semi-works:

results =Blog.multi_search(@query, [Article, MediaFile, MusicTrack])

However, each on of those models has associations. Additionally, I need
to pass :conditions statements (e.g., only find published articles). For
instance, an article has comments, a MusicTrack has albums, genres, and
artists. Right now, this works, but it is not pre-featching associations
or using conditions. Is there a way to enable that like...

results =Blog.multi_search(@query, [Article(:conditions => ['published =
?', yes], :include => [:article_comments], MediaFile, MusicTrack])

--
Posted via http://www.ruby-forum.com/.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise