Sort Options structure

Sort options are different ways in which you can request the results to be sorted. By default results are sorted by relevance (i.e: most relevant items to the query in question come first), but you can choose to sort them by price or any other property. To set up custom sort options for your dataset, please reach out to support@constructor.io.

Sort options structure#

{
"request": {
...
},
"response": {
"facets": [
...
],
"groups": [
...
],
"sort_options": [
{
"sort_by": "relevance",
"sort_order": "descending",
"display_name": "Most Relevant",
"status": "selected"
},
{
"sort_by": "price",
"sort_order": "descending",
"display_name": "Price, High to Low",
"status": ""
},
{
"sort_by": "price",
"sort_order": "ascending",
"display_name": "Price, Low to High",
"status": ""
},
{
"sort_by": "brand",
"sort_order": "ascending",
"display_name": "Brand name, A-Z",
"status": ""
},
{
"sort_by": "brand",
"sort_order": "descending",
"display_name": "Brand name, Z-A",
"status": ""
}
],
"results": [
...
],
"total_num_results": 454
}
}

Sort options fields#

field_nameAlways present?Description
sort_byYesThe name of the attribute results will be sorted by. The value of this field should be passed to the sort_by query string parameter in the search request when this option is selected.
sort_orderYesEither "descending" or "ascending". The value of this attribute should be passed to the sort_order query string parameter in the search request when this option is selected.
display_nameYesThe user-friendly name of this sort option that should be displayed to users.
statusYes"selected" if this option is selected in the current search request, empty string ("") otherwise.