Hi Pat, Now that I have it working I will have you look at my blog post and see if there's anything I am doing wrong. I created the post to help others, but I want to be sure the content is correct. If you have a moment, please read through it, and I apologize if I made some catastrophic mistake. For lack of a better term I had to figure/hack my way through it. I know I have more to learn, but for me, writing it down and re-thinking it always helps. I definitely look forward to your feedback.
In addition, I'm sure I will do some tweaking in my project in the next day or so with additional questions. Here's the post. http://railstrip.ourgreatjourney.com/?p=1 Thanks! Chris On Apr 25, 8:51 pm, Pat Allan <[email protected]> wrote: > Hi Chris > > It's great to hear you've figured out a solution. Like Thuva, I'm not > entirely sure what you're trying to do (one full row per result? two > separate lists of two columns each?), but there's a few approaches, so > I'll go through each, just in case it helps anyway. > > A: Searching across both models in one search call. > - ThinkingSphinx::Search.search "pat" > - Will return both Accounts and Names > - Will return 20 items *total* per page - not 20 or 10 of each > > B: Search both models separately > - Name.search "pat", Account.search "pat" > - Will return 20 items (paginated) for each > > C: Search Names, and have account information as part of the name index. > - Name.search "pat" > - Will return 20 names, and can use the associations to get the > account details. > define_index do > indexes first_name, last_name # assuming Name columns > indexes account.description # assuming Account columns > end > > If you need elaboration on any of those, just let me know. Look > forward to seeing the blog post :) > > Cheers > > -- > Pat > > On 26/04/2009, at 12:44 PM, internetchris wrote: > > > > > > > Thuva, > > > I really appreciate your reply. After endless hours of googling, and > > trial and error (best tool for learning), I think I figured it out. I > > am going to post a blog article, and update this thread once I have > > each step outlined. From that point I would love feedback so I know I > > am doing it properly. > > > I will work on documenting everything so at the very least it will > > help someone else down the road. > > > Thanks! > > > Chris > > > On Apr 25, 8:40 pm, Thuva Tharma <[email protected]> wrote: > >> Hello Chris, > > >> It's hard to give a solid example without knowing more about Account > >> and Name models. You need to tell us the names of the fields in your > >> models as well as what fields you want to search on. > > >> Take a look at the code in this pastie:http://gist.github.com/101856 > > >> I hope that will give you a good starting point. I assumed that you > >> want to search on account number, account description, name, and > >> address. You will have to change the field names (i.e. > >> account_number, > >> account_description) to match the fields in your models. > > >> -- Thuva Tharma > > >> On Apr 25, 2:17 pm, internetchris <[email protected]> > >> wrote: > > >>> Ok, so can I simplify my request?? I really need help. Can someone > >>> point me to the correct "function" to use so I know where to > >>> start? I > >>> simply want to have data from 2 models show up in my search results. > >>> If I could at least get the function I could probably hack my way > >>> through it. > > >>> Thanks! > > >>> Chris > > >>> On Apr 24, 10:56 am, internetchris <[email protected]> > >>> wrote: > > >>>> Hey Everyone, > > >>>> I am new to rails and Thinking Sphinx. I tried to use UltraSphinx > >>>> because the "Advanced Rails Recipe" book had an example, and I'm > >>>> not > >>>> good enough yet to gin up my own code. I was able to get it to > >>>> work, > >>>> but when it came to my harder questions there didn't seem to be any > >>>> support community out there like this one. So humbly I come back > >>>> and > >>>> want to say "Good Job Pat" , group is a great resource, and it > >>>> underlies the fact you want to make this plugin better. > > >>>> With that said, can someone point me to a code example that does > >>>> the > >>>> following... > > >>>> I have 2 models "Account" and "Name". > > >>>> Account has_many :names and ... > >>>> Name belongs_to :account > > >>>> I want to place search form in my Application template, and when it > >>>> searches I can search both models, but more importanly I can > >>>> display > >>>> results from both models. My results view is "Results.html.erb" > > >>>> Example of the view.. > > >>>> Account# | Account Description | Name | Address > > >>>> Account#, and Account Description are stored in my Account table, > >>>> and > >>>> Name and Address are stored in my name table. > > >>>> Any articles or codes examples would be helpful. If someone would > >>>> be > >>>> willing to work with me on my specific example I would be willing > >>>> to > >>>> compensate them for their time. I'm not looking for free help, I > >>>> simply want some help on this. I am gonig to go through my project > >>>> today and take out all of the Ultrasphinx junk, and get it back and > >>>> running on ThinkingSphinx. It's so painful to learn something new! > > >>>> Thanks! > > >>>> Chris > >>>> [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
