Class: Sunspot::FacetRow

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/facet_row.rb

Overview

This class encapsulates a facet row (value) for a facet.

Instance Method Summary collapse

Constructor Details

#initialize(facet_value, field) ⇒ FacetRow

:nodoc:



4
5
6
# File 'lib/sunspot/facet_row.rb', line 4

def initialize(facet_value, field) #:nodoc:
  @facet_value, @field = facet_value, field
end

Instance Method Details

#countObject

The number of documents matching the search parameters that have this value in the facet’s field.

Returns

Integer

Document count for this value



30
31
32
# File 'lib/sunspot/facet_row.rb', line 30

def count
  @count ||= @facet_value.value
end

#valueObject

The value associated with the facet. This will be cast according to the field’s type; so, for an integer field, this method will return an integer, etc.

Note that <strong>Time fields will always return facet values in UTC</strong>.

Returns

Object

The value associated with the row, cast to the appropriate type



19
20
21
# File 'lib/sunspot/facet_row.rb', line 19

def value
  @value ||= @field.cast(@facet_value.name)
end