Searchable Fields - Facets and Sorting | Yext Hitchhikers Platform
What You’ll Learn
In this section, you will learn:
- What facets and sorting are
- Facet Configuration and Use Cases
- Sorting Configuration and Use Cases
Overview
Two other configurations you can add to the Search Configuration for a field are facet and sortable. Facets allow users to dynamically interact with the content in the search experience by filtering the results. Sortable fields can be used as a sorting method that is controlled by the user in the search experience (like with facets), by the algorithm in the backend, or both.
Allowing users to interact with the search experience through facets or sorting, as well as telling the algorithm how to sort, will take additional steps that we will cover in future units. In this unit we will cover how to turn on facets and sortable as a searchable field, which is essential for using either.
Facet Configuration, Example, and Best Practices
Facets allow a field to be used as a type of dynamic filter that a user can interact with in the frontend search experience to narrow the search. This is best for structured enum/option fields where there are a finite number of variations across entities.
There are a few additional steps you will need to take in your frontend build, which you will learn about in the Facets module in the Advanced Search track. By setting the facet configuration upfront, you will enable the functionality to return facet filters in the frontend, allowing a user to further refine vertical search results. For now, we’ll look at this example:
- Example Vertical: Jobs
- Example Field: Job Department (
c_jobDepartment
) - Example Field Type: Custom Single Option Select (Options: Revenue, Technology, Delivery, etc)
The filters on the left side of the screenshot below are called Facet filters. Here we’ve added a label to the Job Department facet to show “Job Category” instead.
You can also add the Facet Filter via JSON within the searchableFields
object:
"searchableFields": {
"c_jobDepartment": {
"facet": true
}
}
Sortable Configuration, Example, and Best Practices
Sortable allows a field to be used as a sorting method that is controlled by the algorithm or by the user. Sorting by the algorithm will appear by default, while sorting by the user gives users the option of sorting by specified methods.
There are a few additional steps you will need to take whether you want to allow sorting by the user, the algorithm, or both, which you will learn about in the Sorting module in the Advanced Search track. By setting the sortable configuration upfront, you will enable the functionality to sort results by the algorithm in the backend or the user in the frontend. For now, we’ll look at this example:
- Example Vertical: Events
- Example Field: Event Start Time (
time.start
) - Example Field Type: Profile Field
For the “Upcoming Events” below, we’ve set the event start time as sortable within the Search Configuration. That allows us to use the event start time field to sort. Once we tell the algorithm how to sort, we can return results such that upcoming events are sorted to the top:
There are a few additional steps you will need to take in your frontend build, which you will learn about in the Facets module in the Advanced Search track. By setting the configuration upfront per the above, you will enable the functionality to return facet filters in the frontend, allowing a user to further refine vertical search results. The filters on the left side of the screenshot below are called Facet filters:
You can add also enable sorting via JSON within the searchableFields
object:
"searchableFields": {
"time.start": {
"sortable": true
}
}