Yes, that's correct - scopes are tied to single models, and a global search isn't in the scope of any model. Thus, Thinking Sphinx doesn't try to use any scopes.
I'm afraid there's no way around this beyond adding the filter into the search manually yourself - though if you have thoughts on how TS could be improved in these scenarios, I'm certainly interested to hear them :)
--
Pat
On 17/07/2012, at 7:01 PM, Roger Kind Kristiansen wrote:
> I've just added functionality for setting entries in some of my models as inactive, and I never want to have those returned in a search.
>
> Therefore I added a sphinx_scope and set this as my default_sphinx_scope. This all works perfectly when searching single models, but when performing a search across multiple models it seems this scope is ignored. I glanced quickly at the code, and, it seems this is by design (lib/thinking_sphinx/search.rb:add_default_scope()).
>
> Is that correct, and is there any other way for me to apply the scope to a selection of the models I'm searching?
>
> Cheers,
> Roger K. Kristiansen
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/TUTtbuTPKcoJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
Hi RogerYes, that's correct - scopes are tied to single models, and a global search isn't in the scope of any model. Thus, Thinking Sphinx doesn't try to use any scopes.
I'm afraid there's no way around this beyond adding the filter into the search manually yourself - though if you have thoughts on how TS could be improved in these scenarios, I'm certainly interested to hear them :)
--
PatOn 17/07/2012, at 7:01 PM, Roger Kind Kristiansen wrote:
> I've just added functionality for setting entries in some of my models as inactive, and I never want to have those returned in a search.
>
> Therefore I added a sphinx_scope and set this as my default_sphinx_scope. This all works perfectly when searching single models, but when performing a search across multiple models it seems this scope is ignored. I glanced quickly at the code, and, it seems this is by design (lib/thinking_sphinx/search.rb:add_default_scope()).
>
> Is that correct, and is there any other way for me to apply the scope to a selection of the models I'm searching?
>
> Cheers,
> Roger K. Kristiansen
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/TUTtbuTPKcoJ.
> To post to this group, send email to thinking-sphinx@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphinx+unsubscribe@googlegroups.com.
Not quite - a global search is actually across all indices at once. It's just when these results are translated into ActiveRecord objects, each model receives one find call - but the context of the search results is maintained.
If that wasn't the case, then yes, you'd be right, each model's default scope should be respected - but it doesn't apply in this situation. It's just a single search call, one set of conditions, one set of filters, etc.
Cheers
--
Pat
> > To post to this group, send email to thinkin...@googlegroups.com.
> > To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> > 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 view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/SNyLT9qKSHYJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> > To post to this group, send email to thinking-sphinx@googlegroups.com.
> > To unsubscribe from this group, send email to thinking-sphinx+unsubscribe@googlegroups.com.
> > 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 view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/SNyLT9qKSHYJ.
> To post to this group, send email to thinking-sphinx@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphinx+unsubscribe@googlegroups.com.