Last Updated: January 11, 2017
· bashir

Sorting on multiple fields in tire elasticsearch

If you want to sort on multiple fields, list them in order like follows: do
  query {string query_string}
  sort {by [{:updated_at => 'desc'}, {:num_comments => 'desc'}]}

will return the most recent results with the most commented first.

1 Response
Add your response

I've used

sort do
  by :updated_at, :desc
  by :num_comments, :desc
over 1 year ago ·