Hey all, I had some pressing questions about acts_as_ferret and had not heard about this mailing list yet, so I contacted Jens directly and he was kind enough to answer my questions. I would like to post our exchange here and continue the dialogue in hopes that it''s useful to someone else out there. Question #1: How should I be setting up my form helper? >> Jens'' Response: >> There''s nothing special to do here - just use a normal text_field. >> I usually have a separate Search model class to back my search forms. Question #2: Rather than defining self.full_text_search on each of my 12 models, I am hoping for a cleaner solution, perhaps a module that I can mixin somehow. Also I am pondering the idea of having a separate SearchController so that my search methods are in one place as well. Do you have any guides/suggestions for handling multiple models in a DRY fashion? >> Jens'' Response: >> See above, either create one Search model to handle all searches, or use >> inheritance/mix ins to handle the common things like paging. Depends on >> how your search forms look - if they''re all the same one Search model >> should be enough - just parametrize it with the class you want to search >> on. Question #3: Where exactly does AAF keep the generated index? >> Jens'' Response: >> By default aaf creates the indices in directories named >> RAILS_ROOT/index/RAILS_ENV/model_name. ################ NEW QUESTIONS ################### Re: Search Model 1. Is this just an Active Record object or do I need to set up a database for it as well (if so then with what columns)? 2. Do I need to set up table relationships to the others (has_many)? 3. How do I boost fields within a multisearch statement? Re: Search Display I''ve seen countless examples of pagination code for AAF, but Im still not sure how to write the view code for my search results. You can read more about the issues I am having, along with code examples here => http://pastie.caboo.se/52769 Thanks again to Jens and the helpful people of this community. You rock!
Hey all, I had some pressing questions about acts_as_ferret and had not heard about this mailing list yet, so I contacted Jens directly and he was kind enough to answer my questions. I would like to post our exchange here and continue the dialogue in hopes that it''s useful to someone else out there. Question #1: How should I be setting up my form helper? > Jens'' Response: > There''s nothing special to do here - just use a normal text_field. > I usually have a separate Search model class to back my search forms. Question #2: Rather than defining self.full_text_search on each of my 12 models, I am hoping for a cleaner solution, perhaps a module that I can mixin somehow. Also I am pondering the idea of having a separate SearchController so that my search methods are in one place as well. Do you have any guides/suggestions for handling multiple models in a DRY fashion? > Jens'' Response: > See above, either create one Search model to handle all searches, or use > inheritance/mix ins to handle the common things like paging. Depends on > how your search forms look - if they''re all the same one Search model > should be enough - just parametrize it with the class you want to search > on. Question #3: Where exactly does AAF keep the generated index? > Jens'' Response: > By default aaf creates the indices in directories named > RAILS_ROOT/index/RAILS_ENV/model_name. ################ NEW QUESTIONS ################### Re: Search Model 1. Is this just an Active Record object or do I need to set up a database for it as well (if so then with what columns)? 2. Do I need to set up table relationships to the others (has_many)? 3. How do I boost fields within a multisearch statement? Re: Search Display I''ve seen countless examples of pagination code for AAF, but Im still not sure how to write the view code for my search results. You can read more about the issues I am having, along with code examples here => http://pastie.caboo.se/52769 Thanks again to Jens and the helpful people of this community. You rock!
Sorry about the double-post yall. I am pretty new to this stuff. You can also disregard my previous query on the search results. I made the silly mistake of using form_for instead of form_tag, but have remedied that. I look forward to learning how to use this amazing software properly. Thanks for your time :-)
On 4/10/07, Steven Garcia <steven at housecafemusic.com> wrote:> <snip>Helpful Information</snip> > Thanks again to Jens and the helpful people of this community. You rock!Hi Steven, Thanks for taking the time to post this. This is a great example of how even new users can contribute to an open source project community. It is a pleasure to help users like yourself. As for your questions below, you may have sabotaged yourself by doing the right thing and posting your questions and answers above. I suspect Jens skipped over this email after seeing the initial part of the post without seeing the questions down the bottom. Usually he is very fast to answer (a lot better than me ;-). You might have been better off sending two separate emails. Anyway, I don''t use acts_as_ferret myself but I''ll do my best to answer your questions. Jens, please correct me if I''m wrong.> ################ NEW QUESTIONS ################### > > Re: Search Model > > 1. Is this just an Active Record object or do I need to set up a > database for it as well (if so then with what columns)?I think Jens just uses this model to store the search parameters. (Although you may want to record searches which can be really useful. I''d just do this in a text file though.) If I am correct then no, there is no need to set this up in the database.> 2. Do I need to set up table relationships to the others (has_many)?I guess the answer to the first question answers this one. The Search model wouldn''t have any relationships with any of the acts_as_ferret searchable models. You would either parameterize it so signify which model it should be searching or implement it as a mixin to add the required methods (ie full_text_search and paging methods) to your searchable models.> 3. How do I boost fields within a multisearch statement?I''m not sure what a multisearch statement is. Perhaps multisearch is a method in acts_as_ferret. Anyway, here is an example of how you can boost fields in acts_as_ferret; http://www.ruby-forum.com/topic/96411 Perhaps you already knew this and you are talking about boosting fields in the actual search query. You can boost portions of a query with the ''^'' notation. For example, if we are searching for ''Ferret'', we''d like to make sure that it is the ''Ruby'' kind and not the ''pet'' kind. We could do it like this; ''+Ferret^10.0 Ruby^0.1 -pet'' I hope I''ve answered your question. There is a lot more information about Ferret''s query language in the O''Reilly Ferret shortcut; http://www.oreilly.com/catalog/9780596527853/> Re: Search Display > > I''ve seen countless examples of pagination code for AAF, but Im still > not sure how to write the view code for my search results. You can > read more about the issues I am having, along with code examples here > => http://pastie.caboo.se/52769 > > Thanks again to Jens and the helpful people of this community. You rock!Sorry, without knowing acts_as_ferret I can''t see anything wrong with your example. Hopefully Jens will be able to help you with this one. Cheers, Dave -- Dave Balmain http://www.davebalmain.com/