The content response object

You get a content JSON object in the Sitecore Discover Search and Recommendation response if you send a content object in the request. The response returns each <content_type> added in your request as a separate key with a value object and displays the corresponding values according to the parameters in your request.

The following shows the basic structure of the content object in a response:

{
"content": {
    "<content_type>": {
	"value": [{
           	<content_result>
	}],
	"total_item": 10,
	"n_item": 1,
	"fields": [<content_field_names>]
        }
    }
}

Keys

Depending on your request you may see some or all keys.

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

KeyTypeDescription
content_typeContent type objectSpecific type of content you requested.
fieldsarrayIf you set the get_fields flag to true in the request, you get an array containing all possible content fields.NoteNot all content has a value for every content field. By default, Discover returns a default set of content fields in the result. To set up custom content fields, contact your Sitecore customer representative.

Content type object

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

KeyTypeDescription
valueobjectValue of <content_type>. This is a list of <content_result> objects. Each <content_result> contains corresponding fields and values.
total_itemintegerTotal number of items that match the query for the <content_type>.
n_itemintegerNumber of items returned in the response for each <content_type>.

Content types

The following table lists the currently supported content type. Each content type requires a feed or another data source. Additional content types can be supported on a per customer basis.

<content_type>Description
productProduct catalog

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

KeyTypeDescription
tsintegerServer timestamp in milliseconds.
ridstringUnique, non-human-readable, generated ID of the response.
dtintegerResponse processing time in milliseconds.
urlstringHTML-encoded URL representation of your request. You use the value to query the same request in the URL content type.
n_itemintegerTotal number of items expected per page returned in the response. Discover calculates this from the sum of all <content_type>.n_item.
total_itemintegerTotal number of content items that match the request. Discover calculates this from the sum of all <content_type>.total_item.
page_numberintegerPage number of the response.
total_pageintegerTotal number of pages available for the request.
query2_idstringUnique, non-human-readable, identifier of the <query_string> in your request. The response returns this only if you sent a query object in the request.
redirect_urlstringThe response returns this only if you sent a query.keyphrase in the request and the query is determined to match a redirect rule. The client decides whether to present the search results, or immediately navigate to the redirect URL.

Example

The following code shows a sample content response:

{
    "ts": 1480977544,
    "rid":"response_id_q3",
    "dt": 38
    "url": "searchpage?keyphrase=shirt",
    "query2id": {
        "keyphrase": "keyphrase_id_red"
    },
    "content": {
	"product": {
            "total_item": 15,
	    "n_item": 2,
	    "value": [
	    	{"name": "shirt", "price": 10},
                {"name": "shirt2","price": 20},
	    ]
	},
	"article": {
	    "total_item": 5,
	    "n_item": 1,
	    "value": [
                {"title": "how to match shirts", "img": "http://img.jpg"}
            ]
	}
    },
    "n_item": 3,
    "total_item": 20,   
    "page_number": 1,
    "total_page": 2,
    "dt": 127
}
If you have suggestions for improving this article, let us know!