Method: Elastics::SearchQuery#sort
- Defined in:
- lib/elastics/search_query.rb
#sort ⇒ Object
Takes ‘params` and returns it compatible with elastics. Wraps scalars into array, hashes are converted into arrays, array are passed as is.
{name: :asc, _score: :desc} => [{name: :asc}, {_score: :desc}]
:created_at => [:created_at]
90 91 92 93 94 95 96 97 |
# File 'lib/elastics/search_query.rb', line 90 def sort val = params[:sort] case val when Hash then val.map { |x| Hash[[x]] } when Array then val else val ? [val] : [] end end |