Sorting enables you to manage the order in which the entities appear within a vertical. There are two types of sorting:
- Search Configuration Sorting - will change the order of results returned by the Search API
- Frontend Sorting - will provide UI controls for a user to sort results after they run a search
For example, for events, you may want to set the start time as sortable within the Search configuration. That will allow you to use the event start time field to sort event entities. To learn more about sorting, visit the Sorting (Backend) training unit.
To add Sorting in the UI:
- Click Search in the navigation bar and click on the desired Search experience. You'll land on the Verticals screen.
- Select the vertical you want to add sorting to.
- Click on the Sorting tab.
- Click + Add Sort Rules.
- Select the desired sorting option.
- Select the settings based on the sorting option you selected.
- If you selected Field as the sorting option, select the desired options in the Field and Direction columns.
- If you selected Distance as the sorting option, optionally add distance buckets in meters.
- Once you have added all of your Sorting Rules, click Save.
To add Sorting using the JSON Editor:
- Click Search in the navigation bar and click on the desired Search experience.
- Click Edit in JSON to navigate to your Search Configuration file.
- Enable sorting via JSON within the
searchableFields
object.It should look something like this:
"searchableFields": {
"time.start": {
"sortable": true
}
} - Then, in each vertical, use the
"sortBys”
property to set each sorting option.
It should look something like this:
"sortBys": [
{
"type": "RELEVANCE"
},
{
"direction": "ASC",
"field": "c_acceptingNewPatients",
"type": "FIELD"
}
],
Once you have set your sort rules in the backend, it can also be added to the frontend experience. The steps vary depending on your implementation method:
- Hitchhikers Theme: Sorting Frontend training unit
- Search SDK: SortOptions component
Comments
0 comments
Article is closed for comments.