Class: Sunspot::Facet
- Inherits:
-
Object
- Object
- Sunspot::Facet
- Defined in:
- lib/sunspot/facet.rb
Overview
The facet class encapsulates the information returned by Solr for a field facet request.
See wiki.apache.org/solr/SolrFacetingOverview for more information on Solr’s faceting capabilities.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
-
#field_name ⇒ Object
The name of the field that contains this facet’s values.
-
#initialize(facet_values, field) ⇒ Facet
constructor
:nodoc:.
-
#rows ⇒ Object
The rows returned for this facet.
Constructor Details
#initialize(facet_values, field) ⇒ Facet
:nodoc:
14 15 16 |
# File 'lib/sunspot/facet.rb', line 14 def initialize(facet_values, field) #:nodoc: @facet_values, @field = facet_values, field end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
12 13 14 |
# File 'lib/sunspot/facet.rb', line 12 def field @field end |
Instance Method Details
#field_name ⇒ Object
The name of the field that contains this facet’s values
Returns
- Symbol
-
The field name
24 25 26 |
# File 'lib/sunspot/facet.rb', line 24 def field_name @field.name end |
#rows ⇒ Object
The rows returned for this facet.
Returns
- Array
-
Collection of FacetRow objects, in the order returned by Solr
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sunspot/facet.rb', line 34 def rows @rows ||= begin rows = [] @facet_values.each_slice(2) do |pair| rows << new_row(pair) end rows end end |