module ThinkingSphinx::ActiveRecord::Base::ClassMethods
Public Instance Methods
facets(query = nil, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 17 def facets(query = nil, options = {}) merge_search ThinkingSphinx.facets, query, options end
search(query = nil, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 21 def search(query = nil, options = {}) merge_search ThinkingSphinx.search, query, options end
search_count(query = nil, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 25 def search_count(query = nil, options = {}) search_for_ids(query, options).total_entries end
search_for_ids(query = nil, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 29 def search_for_ids(query = nil, options = {}) ThinkingSphinx::Search::Merger.new( search(query, options) ).merge! nil, :ids_only => true end
Private Instance Methods
default_sphinx_scope?()
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 37 def default_sphinx_scope? respond_to?(:default_sphinx_scope) && default_sphinx_scope end
default_sphinx_scope_response()
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 41 def default_sphinx_scope_response [sphinx_scopes[default_sphinx_scope].call].flatten end
merge_search(search, query, options)
click to toggle source
# File lib/thinking_sphinx/active_record/base.rb, line 45 def merge_search(search, query, options) merger = ThinkingSphinx::Search::Merger.new search merger.merge! *default_sphinx_scope_response if default_sphinx_scope? merger.merge! query, options if current_scope && !merger.search.options[:ignore_scopes] raise ThinkingSphinx::MixedScopesError, 'You cannot search with Sphinx through ActiveRecord scopes' end result = merger.merge! nil, :classes => [self] result.populate if result.options[:populate] result end