Class: Sunspot::QueryFacet
- Inherits:
-
Object
- Object
- Sunspot::QueryFacet
- Defined in:
- lib/sunspot/query_facet.rb
Overview
QueryFacet instances encapsulate a set of query facet results. Each facet corresponds to a group of rows defined inside a DSL::FieldQuery#facet block.
Instance Method Summary collapse
-
#initialize(outgoing_query_facet, row_data) ⇒ QueryFacet
constructor
:nodoc:.
-
#rows ⇒ Object
Get the rows associated with this query facet.
Constructor Details
#initialize(outgoing_query_facet, row_data) ⇒ QueryFacet
:nodoc:
7 8 9 |
# File 'lib/sunspot/query_facet.rb', line 7 def initialize(outgoing_query_facet, row_data) #:nodoc: @outgoing_query_facet, @row_data = outgoing_query_facet, row_data end |
Instance Method Details
#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
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sunspot/query_facet.rb', line 19 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 << QueryFacetRow.new(row.label, @row_data[row_query]) end end rows.sort! { |x, y| y.count <=> x.count } end end |