Class: Sunspot::Facet

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

Overview

The facet class encapsulates the information returned by Solr for a particular facet request.

See wiki.apache.org/solr/SolrFacetingOverview for more information on Solr’s faceting capabilities.

Instance Method Summary collapse

Constructor Details

#initialize(facet_values, field) ⇒ Facet

:nodoc:



10
11
12
# File 'lib/sunspot/facet.rb', line 10

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

Instance Method Details

#field_nameObject

The name of the field that contains this facet’s values

Returns

Symbol

The field name



20
21
22
# File 'lib/sunspot/facet.rb', line 20

def field_name
  @field.name
end

#rowsObject

The rows returned for this facet.

Returns

Array

Collection of FacetRow objects, in the order returned by Solr



30
31
32
33
34
35
# File 'lib/sunspot/facet.rb', line 30

def rows
  @rows ||=
    @facet_values.map do |facet_value|
      FacetRow.new(facet_value, @field)
    end
end