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.
Written by Bashir Eghbali
Related protips
1 Response
I've used
sort do
by :updated_at, :desc
by :num_comments, :desc
end
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#