Sorting
By default, the search results in Sitecore Search are sorted in descending order of relevance, with the most relevant result appearing at the top. You can define different methods for sorting using sorting options. Sorting options make it possible for your site visitors to change the order of results in the UI. You can create a sorting option using either of the following:
-
Algorithmic sorting - uses the same method of sorting as the default (descending by relevancy score).
-
Attribute sorting - orders search results using an attribute such as ratings, title, or date last modified, in either ascending or descending order.
The following screenshot shows some Sitecore.com search results alongside three methods for sorting them: Relevance, which is created using algorithmic sorting; Oldest content, which sorts by date last modified attribute values in ascending order; and Newest content, which sorts by date last modified attribute values in descending order.
Adding new sorting options
You can add sorting options on the Feature Configuration tab in the Domain Settings section of the Administration page.
If you want visitors to be able to sort by statistical information such as most viewed or most clicked, you can create a sorting option using the inner attributes from the rfk_stats composite attribute.
When you add a sorting option, you'll be asked to specify the following:
-
Display name - name used to display the sorting option. For example, an option that sorts results by when they were last modified could have a display name of Last Modified DESC.
-
API name - name used for the sorting option in API requests. Must be alphanumeric with no spaces, so use underscores (_) to separate words if needed.
-
Sorting type - method used to sort. Available options are algorithmic sorting and attribute sorting.
-
Attribute - attribute to sort by. For example, to sort by content items' titles, set this to the title attribute. This option is only available for attribute sorting.
-
Sorting direction - direction to sort in. Available options are ascending and descending.
-
Analyzer - type of analyzer, if any, to use for transforming input text. Available options are No analyzer, which is the default, and Lowercase. This option is only available for attribute sorting.
Any time you add a sorting option, you can add a second option as a tie breaker. This is useful for attributes where multiple content items have the same value. With these attributes, you might want to add a secondary option that uses algorithmic sorting. This secondary option uses relevancy scores to break ties between content items with the same value for the attribute, causing the more relevant items to be shown higher in the results list.
If the request does not identify a sort option, the configured option is used.