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:
Keys
Depending on your request you may see some or all keys.
The following table describes the keys in the content response object:
| Key | Type | Description |
|---|---|---|
| content_type | Content type object | Specific type of content you requested. |
| fields | array | If 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:
| Key | Type | Description |
|---|---|---|
value | object | Value of <content_type>. This is a list of <content_result> objects. Each <content_result> contains corresponding fields and values. |
total_item | integer | Total number of items that match the query for the <content_type>. |
n_item | integer | Number 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 |
|---|---|
product | Product catalog |
Related keys
The following table describes the keys related to the content response:
| Key | Type | Description |
|---|---|---|
ts | integer | Server timestamp in milliseconds. |
rid | string | Unique, non-human-readable, generated ID of the response. |
dt | integer | Response processing time in milliseconds. |
url | string | HTML-encoded URL representation of your request. You use the value to query the same request in the URL content type. |
n_item | integer | Total number of items expected per page returned in the response. Discover calculates this from the sum of all <content_type>.n_item. |
total_item | integer | Total number of content items that match the request. Discover calculates this from the sum of all <content_type>.total_item. |
page_number | integer | Page number of the response. |
total_page | integer | Total number of pages available for the request. |
query2_id | string | Unique, 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_url | string | The 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: