How to default sort results
These instructions apply only to the Search UI Widgets. Find documentation for other integration methods here: https://docs.search.io/developer-documentation/fundamentals/api-and-client-libraries
By default search results are returned in the order we deem to be the most relevant to the search query.
However, you may wish to override this behaviour. In order to do so, you can add a simple single line of code to your Search Widgets that will order the results the way you desire.
To do so add the following line to the variables
object in your Search Results Widget:
"variables": {
"sort": "price"
},
This will sort on the price
field, ordering results from low to high. To order from high to low simply change to the following:
"variables": {
"sort": "-price"
},