te8bbq
Last Updated: January 11, 2017
·
6.787K
· bashir

Sorting on multiple fields in tire elasticsearch

If you want to sort on multiple fields, list them in order like follows:

tire.search(options) 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

4003

I've used

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