Search relevance is something that everyone should understand but only a few pay enough attention to. In this blog post, my goal is to demonstrate the art of sorting search results without creating rocket-science-complex custom ranking models.

There are several options, though, which are worth to be aware of. Some of them are even easy-to-implement, so you can get an instant boost to your results’ relevance. Let’s check it out the most powerful operators that is called: XRANK.

Sorting search results by a single property

In some cases, you need the search results ordered by a single property. For example, in the “Latest documents” result set the documents might be ordered by the last modified date, in a descending order.
Or in a search-driven site directory, the sites are ordered alphabetically.

Ordering the search results by a single property is easy, both on-prem and online.

To do this on a specific page, follow these steps:

  1. Go to you search center, and open the search page for Edit.
  2. Select the Search Results Web Part, and edit its properties.
  3. Click on “Change Query”.
  4. Select “Sorting” in the top navigation.
  5. Click on Sort by / Select property, then select LastModifiedTime.
  6. Select Descending.query-sort-by-single-managed-property
  7. Click OK, and save your page.


Please note, that the Managed Property you want to sort your results by, has to be sortable.

It’s also possible to change the default sorting for a whole Result Source. For example, you might be interested in seeing your invoices always ordered by time, in descending order, regardless of which page they are returned as results on.

In this case, what you have to do is to create a Query Rule first, applied to the proper Result Source:

  1. Go to your site or site collection settings, and open Search Query Rules.
  2. Select the proper Result Source.
  3. Click on “New Query Rule”.
  4. Give your new Query Rule a name: All invoices.
  5. Under Context, click on Remove Condition, as you want to run this Query Rule for each query against this Result Source.
  6. Under Actions, select Change ranked results by changing the query.
  7. In the query builder, follow the steps described above (from step 4. Select Sorting…)
  8. Save your Query Rule.


Using Query Rules and XRANK

Besides ordering the results by one specific Managed Property, Query Rules can do much more.

Let me introduce XRANK to you: The XRANK operator allows dynamic control over ranking. It boosts the dynamic rank of items based on certain term occurrences without changing which items that match the query.


Share point search



What does it mean in practice?

In the following XRANK expression, for example, in the following KQL expression PDF files get quite a large boost in their dynamic rank value:

{searchboxquery} (fileextension:pdf) XRANK(NB=2.5)

If using this Query Rule with a Documents Result Set, the ranking of PDF files will be improved significantly.

Another way XRANK can be used is to boost content freshness. See Mikael Svenson’s great article about this topic HERE.

Of course, finding the right ranking option and boost value is always a trial-and-error process, until you finally find the one that your users need. Don’t be afraid of try, test, and collect feedback from the users.