I have a working search using SOLR in a Rails 3 app. My controller returns results in pubdate order. I am trying to sub-order by the Section.name. How can I add the child field to the order-by syntax?
Here is my code:
@stories = Story.search do
paginate(:page => params[:page])
order_by :pubdate, :desc
order_by :section_id <---want to suborder by Section.name
fulltext params[:search_query]
end
You would need to add the section name to the parent field to be able to sort it using the Section name.
You can check on Solr Join feature for any JIRA to enable sorting on the Child fields.
Documentation mentions :-
For people who are used to SQL, it's important to note that Joins in
Solr are not really equivalent to SQL Joins because no information
about the table being joined "from" is carried forward into the final
result. A more appropriate SQL analogy would be an "inner query"