The content request object

Add a content JSON object in a Sitecore Discover Search and Recommendation request to specify the type of content you want to see in the search results. To further customize results, you can specify the maximum number of results, sorting type, and fields displayed for each <content_type> in the request.

The following shows the structure of the content object in a request:

{
    "content": {
	"<content_type>": {
		"max": 10,
		"sort": {
			"type": "text",
			"order": "asc"
		},
		"get_fields": false,
		"field": {
			"value": [
                            "<content_field>"
                        ]
		}
	}
    }
}

Keys

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

KeyTypeDescriptionValue
content_typeContent type objectRequired.

Type of content that can be queried one at a time or multiple instances at a time.

Each content type requires a feed or another data source.

The only out-of-the-box content_type we support is product.

Default: product
product

Content type object

The following table describes the keys in the content type object:

KeyTypeDescription
maxintegerOptional.

Limits the number of results of the content returned per page.

Default: n_item
sortSort objectOptional.

Determines the sort order of the <content_type>

Example:

csharp<br>{"type": "text",<br> "order": "asc"}<br>
get_fieldsBooleanOptional.

If you set this to true, the response returns a list of all possible content field names.

Default: false
fieldarray of stringsOptional

The available <content_field> per <content_type> in the query.

Sort object

The following table describes the keys in the sort object:

KeyTypeDescriptionValue
typestringRequired.Whether you want to sort content alphabetically or by the number of items that have this value.For example, a search result has five red and four blue items. If you specify the sort type as count, the red items appear first because there are more red items than blue.count (default)text
orderstringRequired.Whether you want to sort content in an ascending or descending order.desc (default)asc

The following table describes the keys related to the content object:

KeyTypeDescription
n_itemintegerOptional.Total number of the items to be returned for all <content_types> requested in the content object.NoteThe n_item you specify impacts the latency of the request. We recommend you use a value of less than or equal to 48, typically, between 10 and 24. Any number greater than 48 might degrade the latency of the request, and SLAs cannot be guaranteed.Default: 10
page_numberintegerOptional.Page number to be returned. The page contains a maximum of n_item items.NoteThe page_number does not return the maximum number of n_item items if there are not enough items on the last page or if querying content does not have enough pages.Default: 1Example
request for page_number 5 gives you content to be shown on the 5th page.

Example

The following code shows a request to get the name and price of 10 products:

{
    "n_item": 10,
    "content": {
        "product": {
            "field": {
                "value": [
                    "price"
                ]
            }
        }
    }
}
If you have suggestions for improving this article, let us know!