2

If I run a normal search query via the content search API, sorted by an indexed date field, it is not sorting the results correctly. I have checked that the sort field on the Solr managed schema is in fact a date field (pdate), and the managed schema populate is generating it as indexable=true.

What else is there to check / steps to resolve this issue?

1 Answer 1

4

This is a long known issue with Solr, where if a field is stored / has analyzers / is tokenized, it returns incorrect results. This is vaguely mentioned on the documentation here.

It was blogged about years ago by Rich Seal here who said that you can add a copyField with parameters indexed="true" stored="false" and then sort by that field.

This method works well, however it is somewhat of a pain to modify the managed schema manually for this, and then there's always the likelihood that someone will click "Populate managed schema" in Sitecore and overwrite it.

So I have updated the SmartSolrSchema module to include a sortable date computed field that you can use to quickly add any date fields that you need to sort by, which works nicely with the normal "Populate managed schema" in Sitecore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.