Aside from replying directly to Pat yesterday, I thought for the benefit of anyone that comes by this discussion at a later date having similar problems, I would mention in public that following Pat's advice seems to have solved my issue. Thanks Pat!
Regards, Jonny On Jan 25, 3:48 am, Pat Allan <[email protected]> wrote: > This is because you can't use strings for filters, and TS doesn't > automatically attempt .to_i on strings. This has been patched relatively > recently, so it'll be included in the next gem release, but for the moment, > you'll need to do it yourself... ie: > > :with => {:suburb_state_id => params[:search][:state_id].to_i} > > Also - you'll probably want suburb names (and maybe postcodes) as fields, not > attributes, because of the lack of support for strings as attributes. This > will change in the next version of *Sphinx*, but I've no idea when that will > be released. > > Hope this helps > > -- > Pat > > On 24/01/2010, at 12:13 PM, jonny_noog wrote: > > > Hello, > > > I have three models that I've set up to be indexed using TS. I wish > > for the results to be returned in one search and I then take care of > > displaying the different model objects in different ways in my view. > > > I have set things up so that the TS define_index method in each model > > can be essentially the same (the attribute aliases are named the same > > thing across all three models): > > > # Thinking Sphinx options > > define_index do > > indexes :name, :sortable => true > > has suburb.state_id, :as => :suburb_state_id > > has suburb.name, :as => :suburb_name > > has suburb.postcode, :as => :suburb_postcode > > has enabled > > end > > > In my Searches controller I have: > > > unless params[:search][:q].blank? > > �...@results = ThinkingSphinx.search(params[:search][:q], > > :with => { :enabled => true, > > :suburb_state_id => > > params[:search][:state_id], > > :suburb_name => > > params[:search][:suburb_name], > > :suburb_postcode => > > params[:search][:suburb_postcode] }) > > else > > �...@results = nil > > end > > > Everything works fine when only params[:search][:q] contains a string, > > I get the expected results back. But as soon as params[:search] > > [:state_id] or params[:search][:suburb_name] or params[:search] > > [:suburb_postcode] actually contain anything, I get an error like: > > > undefined method `>>' for "7":String > > > "7" being the value that params[:search][:state_id] contains. can > > anyone tell me what I'm doing wrong here? > > > -- > > 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 > > athttp://groups.google.com/group/thinking-sphinx?hl=en. -- 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.
