Your response wasn't nearly as delayed as mine, no worries, good to know you 
got it figured out :)

-- 
Pat

On 27/04/2010, at 2:32 AM, Tom Cocca wrote:

> Hey Pat,
> 
> Sorry I didn't get back to group earlier either (totally forgot).  After 
> digging through the code for a few hours (more than should have been 
> necessary unfortunately) I finally realized that TS works sort of like the 
> way ARel works in rails 3.  It doesn't actually execute the search query and 
> the populate the variable until you call it like an array (.each or .to_a) or 
> something.
> 
> This is where the problem was, I was setting 2 separate searches in the model 
> but not using results to very late in the view rendering, so it was always 
> using the second query for both searches as it just stores the options but 
> the options were getting overrwritten for the first set when the second time 
> TS#search was called.
> 
> So to get around this you need to make TS populate the results set sooner in 
> the request (force it to populate on variable instantiation)
> 
> search_sets = {}
> 
> search_args1 = {:with => {:service_id => 1, :price => 0..100}}
> search_args2 = {:with => {:service_id => 2, :price => 0..100}}
> 
> search_sets['1'] = MyModel.search(search_args1.merge(:populate => true))
> search_sets['2'] = MyModel.search(search_args2.merge(:populate => true))
> 
> adding the .merge(:populate => true)  to the args for TS solved my issue and 
> now everything is working.
> 
> Again, sorry for the extremely delayed response here.
> ~ Tom
> 
> On Sat, Apr 24, 2010 at 12:57 AM, Pat Allan <[email protected]> wrote:
> Hi Tom
> 
> Sorry I've not gotten back to you sooner on this - and unfortunately I can't 
> reproduce it in my limited testing. If you can do so reliably, would 
> appreciate a basic test app so I can do the same locally.
> 
> Given it's been a few weeks, maybe you've found a solution anyway?
> 
> --
> Pat
> 
> On 07/04/2010, at 3:44 AM, Tom Cocca wrote:
> 
> > We have a really weird requirement, we need to perform searches on a
> > model for two (or more) different items which belong to a service
> > however we are not allowed to mix result sets together.  What this
> > means is that we need to actually perform 2 distinct sphinx queries.
> > The problem is when I try and do this it ignores all searches except
> > the last one.
> >
> > for example:
> >
> > search_sets = {}
> >
> > search_args1 = {:with => {:service_id => 1, :price => 0..100}}
> > search_args2 = {:with => {:service_id => 2, :price => 0..100}}
> >
> > search_sets['1'] = MyModel.search(search_args1)
> > search_sets['2'] = MyModel.search(search_args2)
> >
> > The results set is always the same for both.  It seems to take the
> > last search that gets called and execute that for everytime the search
> > method gets called.
> >
> > Any ideas? Thoughts?
> >
> > I would love to be able to do 1 search and then split things out based
> > on service_id but I need to maintain pagination and it doesn't seem
> > like the grouping functionality is going to provide what I need.
> >
> > Thanks,
> > ~ Tom
> >
> > --
> > 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.
> >
> 
> --
> 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.
> 
> 
> 
> -- 
> 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.

-- 
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.

Reply via email to