Hi, as I just happened to explain in a previous post, Ferret can index data returned from arbitrary methods, as well as ActiveRecord attributes.
you could Ferret index only your Article model and write a method, say comment_content, that returns the content of all the comments, and index that. It does mean that you'll need to reindex the associated Article when a comment is added/updated (an after_save method on your Comment method will do). Tbh though, it's really not very scalable because the entire content of all the comments for the associated Article needs to be reindexed each time. If you're looking at a lot of comments here, then this might not be the best solution. Anyone know if there is a way to update an index field by merging in new content, rather than having to replace it? John. On Tue, 2007-04-24 at 13:43 +0200, Allen Young wrote: > Hi all, > > I'm quite new to ferret and acts_as_ferret and what to see if I can > implement the following requirement using them. > > Suppose I have two model classes: Article and Comment. It's obvious that > one article may have many comments, so this is a one-many relationship. > If I want to add full text search to these models, I'm supposed to use > acts_as_ferret in both of the classes. > > Now say I what to search for "rails" in all of these documents, ferret > will simply return all the models it found, say article1, comment1 and > comment2. The problem is that, there is a chance(and not that small) > that comment1 or/and comment2 belong(s) to article1, in which case I > want to show just article1 with all its comments. > > Of course I can go through the result set and write some logic to do > this. But I think acts_as_ferret should be able to solve at least part > of this problem. Is there an existing way to do this? If not, is there > any thought about adding this in the future? > > Thanks. > -- http://johnleach.co.uk _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

