The sort request object

You can add a sort JSON object in a Sitecore Discover Search and Recommendation request. You use a value object to specify the order of the content search results. The value object contains a list of objects, and each object contains a sort type and order type.

Note

You set up the default and available sort values in the Customer Engagement Console (CEC) when you first create an account with Discover.

The following code shows the structure of a sort object in a request:

RequestResponse
{
    "sort": {
	"value": [{
           "type": "<sort_type>",
	   "order": "<order_type>" 
            }
    	]
     }
}

Keys

The following table describes the key that the sort object contains.

Key

Type/default value

Description

value

Sort object

Optional.

Determines the sort order of the content results based on the <sort_type> and <order_type>.

Sort object

The following table describes the keys in the sort object:

Key

Type

Description

Value

type

string

Required.

The sort types you want to sort by.

  • featured (default)

  • name

  • price

  • newest

  • rating

  • review

order

string

Required.

Whether you want to sort in an ascending or descending order.

  • asc (default)

  • desc

Sort types

We typically support the following sort types:

Sort

Description

featured

Sort by a mix of vendor rules, popular, individualized.

name

Sort by name.

price

Sort by price.

newest

Sort by recently added.

rating

Sort by product review rating.

review

Sort by the number of reviews.

Note

See the CEC for the sort choices applicable to your account.

Example

You need a request to search for red products and then:

  • Sort by price from high to low (desc)

  • If the price is the same, sort by name alphabetically (asc)

This is a sample request:

RequestResponse
{
    "query": {
	"keyphrase": ["red"]
    },
    "n_item": 3,
    "content": {},
    "sort": {
    	"value": [{
        	"type": "price",
		"order": "desc"
	    },
	    {
		"type": "name",
		"order": "asc"
	    }
	]
    }
}

For more examples, see Sorting content results.

Do you have some feedback for us?

If you have suggestions for improving this article,