Module: ThinkingSphinx::ActiveRecord::Search

Defined in:
lib/thinking_sphinx/active_record/search.rb

Overview

This module covers the specific model searches - but the syntax is exactly the same as the core Search class - so use that as your refence point.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/thinking_sphinx/active_record/search.rb', line 8

def self.included(base)
  base.class_eval do
    class << self
      # Searches for results that match the parameters provided. Will only
      # return the ids for the matching objects. See
      # ThinkingSphinx::Search#search for syntax examples.
      #
      def search_for_ids(*args)
        options = args.extract_options!
        options[:class] = self
        args << options
        ThinkingSphinx::Search.search_for_ids(*args)
      end

      # Searches for results limited to a single model. See
      # ThinkingSphinx::Search#search for syntax examples.
      #
      def search(*args)
        options = args.extract_options!
        options[:class] = self
        args << options
        ThinkingSphinx::Search.search(*args)
      end

      def search_count(*args)
        options = args.extract_options!
        options[:class] = self
        args << options
        ThinkingSphinx::Search.count(*args)
      end

      def search_for_id(*args)
        options = args.extract_options!
        options[:class] = self
        args << options
        ThinkingSphinx::Search.search_for_id(*args)
      end
    end
  end
end