Hi Paco

You can set a default scope for when you are searching on a single model, like 
so:

  class MyModel < ActiveRecord::Base
    # ...
    
    define_index do
      # ...
    end
    
    sphinx_scope(:default_search) {
      # ...
    }
    default_sphinx_scope :default_search
    
    # ...
  end

But, when you're searching across *all* models, Thinking Sphinx has no 
reference point to a particular model, and thus has no knowledge of each one's 
default scope. There is no 'global' default scope setting.

-- 
Pat

On 18/12/2009, at 8:12 PM, Paco Guzmán wrote:

> Hi all!
> 
> First of all I'm new with thinking sphinx and my english is so bad :(
> 
> Well, I'm trying to define a default_sphinx_scope for some of my
> models and I want to use it with a global search (search of my all
> models included ones without a default_sphinx_scope defined). I'm
> surfing into the library code and I've found this:
> 
> module Thinking Sphinx
>  class Search
>    ...
> 
>    def search(*args)
>      add_default_scope
>      merge_search ThinkingSphinx::Search.new(*args)
>      self
>    end
> 
>    ...
>  end
> end
> 
> So I think is possible what I want but when I try to use it in the
> following manner:
> 
> ThinkingSphinx.search("query term")
> 
> I don't get good results
> 
> In the model with the default_sphinx_scope define I do:
> 
> Model.my_default_scope.search("query term")
> 
> And I get good results
> 
> So Can I use the default_sphinx_scope in a search over all my indexed
> models?
> 
> Thanks in advance
> 
> --
> 
> 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