On Mon, Oct 02, 2006 at 03:30:59PM +0200, Charlie Hubbard wrote: > > I have design question and I'm wondering what's the best way to solve > it. I'm trying to index HTML content where I have a single model object > call it Article that is an acts_as_ferret model, and an article consists > of many HTML files. I would like to index all of the content of the > article with ferret and search across it. However, since the article's > content is spread over several files how would I do that if I don't have > an object in the database for each page? Is there a way from within my > Article object to add more than one Document to the index? These pages > would obviously be attached to the life cycle of the Article. In other > words if I remove the article I want to remove all the pages that went > along with that article. How would I do that?
Do you want to be able to find single html files in search results, or is it ok to only find the whole article, without knowing which file the hit was in ? In the first case, you can either create a Page model representing a single page and index that, or don't use acts_as_ferret at all and do the indexing yourself. The easier way is the second case, just create a method named html_content returning the concatenated contents from all the files belonging to your article, and add :html_content to the fields list in your call to acts_as_ferret. This will index all files belonging to your article in a single Ferret document. > Another question I have is I would like to search the elements of the > article like author, title, etc, and search the contents of those > Articles within one search field. Can I place all of this data inside a > single index? Or do I have to use the multi_search method? you'll only need multi_search if you have several indexes (that is, several Model classes where you called acts_as_ferret). In your case, if you choose the second way, just index your meta data together with the content, aaf will by default search in all fields. cheers, 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

