This is the case for TS in general, 2.x and 1.x - named_scopes have never 
worked with TS. Dealing with what AR creates for scopes just isn't worth the 
hassle, from an internal code perspective.

Sphinx scopes should be fine with :include, they just won't merge when chained. 
Chained :include values from sphinx scopes will overwrite each other.

-- 
Pat

On 24/02/2011, at 11:03 AM, Aaron Gibralter wrote:

> So is that just the case in 1.4.3?
> 
> Does sphinx scope accept :include?
> 
> In any case, I'm fine for now using `with_scope`...
> 
> Thanks again for the help!
> 
> On Wed, Feb 23, 2011 at 6:55 PM, Pat Allan <[email protected]> wrote:
> Hi Aaron
> 
> Yeah, you still can't use named_scopes with search calls. You can redefine 
> the named_scope as a sphinx scope as well, though, then use that?
> 
> --
> Pat
> 
> On 24/02/2011, at 10:52 AM, Aaron Gibralter wrote:
> 
> > Hi Pat,
> >
> > Unfortunately, I haven't gotten a chance to upgrade to Rails 3 so I'm still 
> > using 2.3.11 + TS 1.4.3...
> >
> > This definitely does not seem to work in 1.4.3:
> >
> > Model.named_scope1.sphinx_scope1.sphinx_scope2.search(...)
> >
> > Where named_scope1 is {:include => [...]}
> >
> > I could imagine that it works in TS 2 though...
> >
> > Thanks,
> > Aaron
> >
> > On Wed, Feb 23, 2011 at 6:47 PM, Pat Allan <[email protected]> 
> > wrote:
> > Hi Aaron
> >
> > You should be able to pass through :include into the search call - is this 
> > not working for you in v2?
> >
> > Looking at the code, it should probably work in a basic sense for 
> > sphinx_scopes as well - if you chain scopes with their own :include 
> > setting, then the last one is what's used (ie: include values aren't 
> > merged, unlike :with, :conditions, etc).
> >
> > Cheers
> >
> > --
> > Pat
> >
> > On 24/02/2011, at 10:36 AM, Aaron Gibralter wrote:
> >
> > > The thing is I'm mainly looking to ensure that TS correctly uses :include 
> > > to avoid N+1 queries... I don't think sphinx_scopes help with that...
> > >
> > > I guess I could use search_for_ids... but don't you also have to do:
> > >
> > > @collection = @collection.collect do |item|
> > >   @collection[ids.index(item.id)]
> > > end
> > >
> > > to ensure that the order of the results is preserved?
> > >
> > > Alternatively, this works:
> > >
> > > with_scope(:find => {:include => ...}) do
> > >   Model.search(...)
> > > end
> > >
> > > In that case, Sphinx respects the scope when it preforms the find on the 
> > > ids.
> > >
> > > On Wed, Feb 23, 2011 at 5:52 PM, Clemens Kofler <[email protected]> 
> > > wrote:
> > > I've used search_for_ids successfully in the past like so:
> > >
> > > ids = Model.search_for_ids(... whatever ...)
> > > @collection = Model.active.published.whatever.find(ids)
> > >
> > > The alternative, as was mentioned, is to use sphinx_scope and/or
> > > handle some of that stuff in the index itself. You can, for instance,
> > > choose to only index posts that have published = true if that makes
> > > sense in your business rules (e.g. if the search isn't used in the
> > > backend where you also list/search for unpublished posts).
> > >
> > > - C.
> > >
> > > On Feb 23, 11:11 pm, Aaron Gibralter <[email protected]>
> > > wrote:
> > > > Is this still the case? It seems like named_scope is ignored as of 
> > > > 1.4.3...
> > > > but how about the v2 branch? Does TS support dynamic arel queries?
> > > >
> > > > I could see why conditions, orders, and limits would be ignored... but 
> > > > it's
> > > > tough not being able to include includes to avoid N+1 queries... what's 
> > > > the
> > > > best way to do it? search_for_ids then pass those to a named_scope find?
> > > > with_scope seems to work too...
> > >
> > > --
> > > 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.
> 
> --
> 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