Entity Sorting Overview | Yext Hitchhikers Platform

What You’ll Learn

In this section, you will learn:

  • Refresher on the default sorting methods
  • What is entity sorting and what are the options to customize it?

What is Entity Sorting?

Entity Sorting is the ability to manage the order in which the entities appear within a vertical.

In Search, sorting consists of two main components: 1) the default sort order, specified in the Search configuration file and 2) optional client-side sorting. We’ll first discuss how to control the default sort order, and then review how to add client-side sorting, to allow your users to re-order their results.

The Search configuration has a default sorting built into the backend that does not require any setup called “Relevance” sorting, which we learned about in the Overview of the Search Algorithm track .

As you may recall, the algorithm has a few components to make up the ranking logic but the main ones are 1) Location Radius with Location Intent 2) Relevance and 3) Location Distance.

However, we also have the ability to customize sorting in a couple of ways, should you want to adjust the order of the entities beyond relevance for a particular vertical. You’ll learn how we can do this in this module.

What are the customizable sorting options?

There are four main sort options that are supported and we will show you how to implement these:

  • Relevance (RELEVANCE)
  • Random (RANDOM)
  • Distance (ENTITY_DISTANCE)
  • Ascending or Descending on a custom field (FIELD)

Relevance: As noted above, Relevance is our standard sorting (without the sorting on distance). By default, the algorithm will score based on Relevance, but you can also set it in your configuration to sort by how well entities match the search query.

Random: This will sort entities randomly. A common use case is to sort by Relevance, then Random: if two results have the same quality match, the entities will be sorted randomly per session.

Distance: This is the distance from the users location or the users intended location.

However, sometimes, sorting by distance is too literal. For example, if one location is 500 feet closer than another location, that trivial distance hardly matters to the user. At that point, results should instead be sorted by relevance. The Bucketed Distance feature converts a continuous distance value into a discrete range, making it easier to sort by both distance and relevance.

By a custom field: Any field can be used to sort results. We support number, date, and boolean fields. Text fields are supported for A-Z or Z-A sorting. As part of the configuration, you also need to specify the field and as well as the order it should be sorted: either ascending (triggered by “ASC) or descending (triggered by “DESC”).

What is a default sort order?

The default sort order is the order in which results return for a specific vertical. An Administrator can add a default sort order to the Search Configuration file. Each sorting option can be added under the relevant Knowledge Graph vertical in the configuration.

Note that sorting is applied per vertical and isn’t applied uniformly across all verticals. For example, an administrator for a Financial Services client could apply random sorting to the Advisors vertical or Distance sorting to the Location Branches vertical but neither option would be applied globally across all of the verticals.

What is client-side sorting?

As mentioned, there are two different ways of controlling sorting. You can control the default sorting (via the Search Configuration file) as we discussed above. You can also expose sorting options to the users in Vertical Search. This is set up as part of the Search front end and allows an end user to adjust the sorting algorithm, which we refer to as client-side sorting or “SortOptions” in the configuration.

For example, in product search, you could expose the following sorting widget or the search results page:


We’ll show you in the next unit how to implement sorting both in the backend and in the frontend but first, let’s look at some common use cases for why to implement these.

Common Use Cases for Sorting Options

There are a number of use cases for sorting entities that can arise for an Administrator. At times, it can be beneficial to only use one sorting option and at other times, to combine sorting options among the available verticals for the best results.

Let’s look at a few common use cases:

  • Randomizing “people” results may help avoid unfairness and preferential treatment towards one person over another after sorting by relevance
  • Sorting people based on both availability (Custom Field) and Distance
  • Sorting entities by promotion or release date in combination with relevance
  • Sorting entities by Price (Custom Field) — high to low or low to high — in combination with “Relevance”

These use cases can be particularly applicable in the following industries:

Industry Use Case
Financial Services Randomizing “bankers” or “financial advisors” results to avoid unfairness and preferential treatment towards one person over another.
Retail If new products are released and should be promoted, you can sort by relevance and a release date to prefer those to the top. If some products are more or less expensive than others, you can sort products by price and by relevance to the query
Food Services If you want menu items that are more expensive to be at the top, by relevance to the query and price custom field in descending order
Healthcare Preferring doctors who accept new patients over those that do not.

light bulb
Consider the implications of entity sorting on the user’s experience. Think about the industry your business is in, and where and why this could be suitable.
unit Quiz
+20 points
Daily Quiz Streak Daily Quiz Streak: 0
Quiz Accuracy Streak Quiz Accuracy Streak: 0
    Error Success Question 1 of 2

    Which of the following is the default sorting option for the Search algorithm without any customization?

    Error Success Question 2 of 2

    Where do you update the default sort order and client-side sorting (sortOptions)?

    Climbing that leaderboard! 📈

    You've already completed this quiz, so you can't earn more points.You completed this quiz in 1 attempt and earned 0 points! Feel free to review your answers and move on when you're ready.
1st attempt
0 incorrect