Class: Sunspot::FacetData::QueryFacetData
- Defined in:
- lib/sunspot/facet_data.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(outgoing_query_facet, row_data) ⇒ QueryFacetData
constructor
:nodoc:.
- #name ⇒ Object
-
#rows ⇒ Object
Get the rows associated with this query facet.
Methods inherited from Abstract
Constructor Details
#initialize(outgoing_query_facet, row_data) ⇒ QueryFacetData
:nodoc:
88 89 90 91 |
# File 'lib/sunspot/facet_data.rb', line 88 def initialize(outgoing_query_facet, row_data) #:nodoc: @outgoing_query_facet, @row_data = outgoing_query_facet, row_data @field = @outgoing_query_facet.field end |
Instance Method Details
#name ⇒ Object
93 94 95 |
# File 'lib/sunspot/facet_data.rb', line 93 def name outgoing_query_facet.name end |
#rows ⇒ Object
Get the rows associated with this query facet. Returned rows are always ordered by count.
Returns
- Array
-
Collection of QueryFacetRow objects, ordered by count
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/sunspot/facet_data.rb', line 105 def rows @rows ||= begin rows = [] for row in @outgoing_query_facet.rows row_query = row.to_boolean_phrase if @row_data.has_key?(row_query) rows << yield(row.label, @row_data[row_query]) end end rows.sort! { |x, y| y.count <=> x.count } end end |