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:
|
Key |
Type |
Description |
|---|---|---|
|
|
Specific type of content you requested. | |
|
|
array |
If you set the Note Not 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 |
|---|---|---|
|
|
object |
Value of |
|
|
integer |
Total number of items that match the query for the |
|
|
integer |
Number of items returned in the response for each |
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 catalog |
Related keys
The following table describes the keys related to the content response:
|
Key |
Type |
Description |
|---|---|---|
|
|
integer |
Server timestamp in milliseconds. |
|
|
string |
Unique, non-human-readable, generated ID of the response. |
|
|
integer |
Response processing time in milliseconds. |
|
|
string |
HTML-encoded URL representation of your request. You use the value to query the same request in the URL content type. |
|
|
integer |
Total number of items expected per page returned in the response. Discover calculates this from the sum of all |
|
|
integer |
Total number of content items that match the request. Discover calculates this from the sum of all |
|
|
integer |
Page number of the response. |
|
|
integer |
Total number of pages available for the request. |
|
|
string |
Unique, non-human-readable, identifier of the |
|
|
string |
The response returns this only if you sent a |
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
}