[Answered ]-Sorting Order in Django Haystack SOLR

2👍

Add sortMissingLast="true" to the field that shall have the behaviour. After that ordering ascending or descending by that field will put the null values last. As far as I know this change will require you to re-index, before it takes effect.

<field name="sort_date" type="date" indexed="true" stored="true"
 multiValued="false" sortMissingLast="true" />

<field name="sort_date_exact" type="date" indexed="true" stored="true"
 multiValued="false" sortMissingLast="true" />

There have been some issues prior to Solr 3.5, which you can read up in the related question Sorting dates using Solr is messing up some dates. As I do not know which version you use, this could be of interest.

👤cheffe

Leave a comment