Method: Sunspot::DSL::FieldQuery#order_by
- Defined in:
- lib/sunspot/dsl/field_query.rb
#order_by(field_name, direction = nil) ⇒ Object
Specify the order that results should be returned in. This method can be called multiple times; precedence will be in the order given.
Parameters
- field_name<Symbol>
-
the field to use for ordering
- direction<Symbol>
-
:asc or :desc (default :asc)
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sunspot/dsl/field_query.rb', line 22 def order_by(field_name, direction = nil) sort = if special = Sunspot::Query::Sort.special(field_name) special.new(direction) else Sunspot::Query::Sort::FieldSort.new( @setup.field(field_name), direction ) end @query.add_sort(sort) end |