Configure a sorting option

By default, in Sitecore Search search results are displayed in descending order by relevancy score, but you can create other sorting options. Similarly, you can sort results using visitor interaction metrics such as most clicked on, most viewed, and so on.

The following procedures describe how you can configure sorting options and sorting criteria.

Enable the sorting option feature for an attribute

To add an attribute as a new sorting option, you must first ensure the attribute is enabled with the sorting option feature.

To enable the sorting option feature for an attribute:

  1. On the menu bar, click Administration > Domain Settings > Attributes.

  2. In the Attributes tab, in the search box, enter name of the attribute or the attribute containing the inner attribute, and then click on it in the tabular list.

  3. In the dialog, on the Use For Features tab, select the Sorting Options check box.

  4. Click Apply, then click Save.

  5. Click Publish. Confirm the action when prompted.

Enable the sorting option feature for an inner attribute

Sitecore Search tracks statistics such as clicks, conversions, views, and searches over time periods ranging from 1 day to 90 days. These statistics are stored as inner attributes within the rfk_stats composite attribute. Sitecore Search uses these attributes internally to generate analytic reports, but you can also use them on your site as sorting options.

Before adding an inner attribute as a new sorting option, you must enable it as a sorting option feature.

To enable the sorting option feature for an inner attribute:

  1. On the menu bar, click Administration > Domain Settings > Attributes.

  2. In the Attributes tab, in the search box, enter name of the attribute containing the inner attribute, and then click on it in the tabular list.

  3. On the left vertical menu bar, click the Inner Attributes tab.

  4. In the list of inner attributes, click the inner attribute you want to use for sorting. This opens the inner attribute editing dialog.

  5. In the dialog, on the Use For Features tab, select the Sorting Options check box.

  6. Click Apply, then click Save.

  7. Click Publish. Confirm the action when prompted.

Add a sorting option

After making an attribute available as a sorting option, you must add it to the sorting options list in order for it to be used on your domain.

To add a sorting option:

  1. On the menu bar, click Administration > Domain Setting > Feature Configuration > Sorting Options.

  2. Scroll to the bottom of the list of sorting options, then click Add Sorting Option.

  3. Click Edit at the top of the new sorting option.

  4. In the SORTING OPTIONS PROPERTIES dialog, to provide values:

    1. In the DISPLAY NAME field, enter a short but descriptive name.

      For example, Top viewed this week.

    2. In the API NAME field, enter a name for the sorting option without escape characters and then click Save.

      For example, top_viewed_this_week.

    3. Click Save.

  5. Optionally, to add a sorting criteria, click Add Sorting Criteria.

  6. Edit the sorting criteria.

  7. Click Save, then click Publish. Confirm the action when prompted.

Important

After completing this step, you must reindex your content for the new sorting option to be available for use.

Edit a sorting criteria

After creating a sorting option, you can configure the sorting criteria included in the option. By default, a sorting criteria uses algorithmic sorting and sorts alphabetically ascending.

To edit a sorting criteria:

  1. In the Sorting type drop-down menu, to sort based on an attribute click Attribute Sorting else click Algorithmic Sorting.

  2. For attribute sorting only, in the Name/Title drop-down menu, click attribute.

    For example, to sort by content items' titles, set this to the title attribute.

  3. In the sorting direction drop-down menu, click Ascending or Descending.

  4. For attribute sorting only, in the analyzer drop-down menu, click No analyzer or Lowercase.

    The Lowercase analyzer transforms text to lowercase before sorting.

  5. To publish sorting criteria and all other changes to sorting options, click Save and then click Publish. Confirm the action when prompted.

Important

After completing this step, you must reindex your content for the new sorting option to be available for use.

Turn on the sorting option in the global widget settings

If you do not turn on any sorting options in the global widget settings, the API returns all sorting options created in feature configuration. However, if any sorting options are turned on in the global widget settings, only the ones that are turned on are returned by the API.

Important

We recommend you turn on new sorting options in the global widget. However, if this is not the first sorting option and no other sorting options are turned on, do not complete this step because otherwise, all other sorting options are disabled.

Turning on sorting options in global widget settings allows you to have more control over which sorting options are returned by creating a default configuration that can be overridden at the individual widget level with rules. It also makes it possible to create many potential sorting options in feature configuration and then only turn on the ones you need.

To configure the sorting option in the global widget:

  1. On the menu bar, click Global Resources, then click Global Widget.

  2. On the Global Widget Settings tab, click the Sorting card.

  3. On the card for the new sorting option, turn on the switch.

  4. Optionally, if you want this sorting option to be the default, click Make Default.

  5. Click Save, then click Publish. This opens a dialog. Confirm your changes by clicking Publish again in the dialog.

Important

After completing this step, you must reindex your content for the new sorting option to be available for use.

Do you have some feedback for us?

If you have suggestions for improving this article,