Troubleshooting sorting

Sorting all the results

By default, the search results are grouped into tiers which are then sorted. This means that sorting of the results may seem odd because you choose to sort by title or date but the set of results returned don’t appear to reflect that because all the fully matching results are returned (sorted) then the results matching all by one constraint and so on.

To sort all the results the -sortall=true query processor option must be added to the results page settings.

Sorting by metadata class

  • Check the data model and confirm that the metadata is containing the values you expect.

  • Check that sort isn’t overridden by a plugin.

  • Check that the metadata class you are sorting by is mapped in your metadata mappings, and that the type is appropriate (e.g. you haven’t set up a number type field that contains a text string). If the same metadata class is defined in different data sources that belong to the same search package, ensure these are all configured to be of the same type.

  • Check that the result sorting is not breaking when the result tier changes (result.tier data model element). If the sort is only working for the first tier then you may need to set the -sortall=true query processor option as outlined above.

How can I sort by more than one field?

It is not possible to directly sort the search results by more than one key. If there is a need to do this then it can be achieved by creating a sort key at filter time (but this won’t be suitable for all use cases as the sort key(s) need to be precomputed and indexed as an extra metadata field.) See: Sorting by multiple keys

Random (shuffle) sort

When using random (shuffle) sort it is important to supply an rseed parameter to ensure that the random sort is applied per search session. If rseed is omitted then every search will be completely random meaning that pagination of the search results becomes meaningless, and that you might find some results appearing again on subsequent pages of the results.