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.

Reply via email to