The batch response object
You get a batch JSON object in a Sitecore Discover Search and Recommendation response if you combine multiple requests into a single request. The batch object returns results based on the sequence and dependencies of the objects you added in your request. All results are non-duplicate.
The following shows the basic structure of the batch object in a response:
{
"batch": [
{<response_key>: <response_value>}
]
}
Keys
The following table describes the key in the batch response object:
|
Key |
Type |
Description |
|---|---|---|
|
|
object |
Contains the attribute that needs to be overridden in the batch for a specific request. Discovers overrides the value of this attribute. |
Example
The following code shows an example of a response where the content object is overridden in a batch of two requests.
For the first response, shirt and shirt2 are the product contents. For the second response, shirt3 and shirt4 are the product contents. All other response attributes are the same and are outside of the batch object.
"batch": [
{
"content": {
"product": {
"total_item": 15,
"n_item": 2,
"value": [
{"name": "shirt", "price": 10},
{"name": "shirt2", "price": 20}
]
}
},
{
"content": {
"product": {
"total_item": 15,
"n_item": 2,
"value": [
{"name": "shirt3", "price": 40},
{"name": "shirt4", "price": 50}
]
}
}
]