class ThinkingSphinx::Facet

Attributes

name[R]

Public Class Methods

new(name, properties) click to toggle source
# File lib/thinking_sphinx/facet.rb, line 6
def initialize(name, properties)
  @name, @properties = name, properties
end

Public Instance Methods

filter_type() click to toggle source
# File lib/thinking_sphinx/facet.rb, line 10
def filter_type
  use_field? ? :conditions : :with
end
results_from(raw) click to toggle source
# File lib/thinking_sphinx/facet.rb, line 14
def results_from(raw)
  raw.inject({}) { |hash, row|
    hash[row[group_column]] = row["sphinx_internal_count"]
    hash
  }
end

Private Instance Methods

group_column() click to toggle source
# File lib/thinking_sphinx/facet.rb, line 23
def group_column
  @properties.any?(&:multi?) ? "sphinx_internal_group" : name
end
use_field?() click to toggle source
# File lib/thinking_sphinx/facet.rb, line 27
def use_field?
  @properties.any? { |property|
    property.type.nil? || property.type == :string
  }
end