Search code examples
solrsunspotsunspot-rails

Sunspot order_by sort with nil values being last


I am trying to order the Sunspot search results by price from the smaller to bigger values.

order_by :price, :asc

However there are some items which have nil price values. They are placed at the front of results. Is there a good way to display those at the end instead of leaving them out?


Solution

  • add an attribute "sortMissingLast=true" to the price field's definition in the schema.xml