Class: ThinkingSphinx::FacetSearch

Inherits:
Hash
  • Object
show all
Defined in:
lib/thinking_sphinx/facet_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FacetSearch

Returns a new instance of FacetSearch.



5
6
7
8
9
10
11
12
13
14
# File 'lib/thinking_sphinx/facet_search.rb', line 5

def initialize(*args)
  ThinkingSphinx.context.define_indexes
  
  @options      = args.extract_options!
  @args         = args
  
  set_default_options
  
  populate
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/thinking_sphinx/facet_search.rb', line 3

def args
  @args
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/thinking_sphinx/facet_search.rb', line 3

def options
  @options
end

Instance Method Details

#facet_namesObject



27
28
29
30
31
32
33
34
35
# File 'lib/thinking_sphinx/facet_search.rb', line 27

def facet_names
  @facet_names ||= begin
    names = options[:all_facets] ?
      facet_names_for_all_classes : facet_names_common_to_all_classes
    
    names.delete "class_crc" unless options[:class_facet]
    names
  end
end

#for(hash = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/thinking_sphinx/facet_search.rb', line 16

def for(hash = {})
  for_options = {:with => {}}.merge(options)
  
  hash.each do |key, value|
    attrib = ThinkingSphinx::Facet.attribute_name_from_value(key, value)
    for_options[:with][attrib] = underlying_value key, value
  end
  
  ThinkingSphinx.search *(args + [for_options])
end