The batch request object
You can add a batch JSON object in a Sitecore Discover Search and Recommendation request. You can combine multiple requests into a batch object and specify the sequence and dependencies between related requests.
For example, when you work with recommendations, group requests for distinct recommendation widgets into a single object instead of creating individual requests. Then, when you have multiple recommendation widgets on the same page, the batch object returns non-duplicate results in the response. This ensures that you do not see the same product twice on a page.
The following shows the structure of a batch object in a request:
{
"batch": [{
"<request_key>": {
"<request_key_id>": "<request_value>"
}
}]
}Keys
The following table describes the key that the batch object contains.
|
Key |
Type |
Description |
|---|---|---|
|
|
object |
Required. Key that Discovers overrides for the batch. The key value is the overridden value. |
Example
The following shows an example of a batch request to override the filter object and the corresponding widget IDs for a batch of 2 requests:
-
For the first request, you want to apply a filter to
category_id1 andcolorred. -
For the second request, you want to apply a filter to
category_id2 andcolorblue
Here is the sample request:
{
"batch": [{
"filter": {
"category_id": "1",
"colors": "red"
},
"widget": {
"rfkid": "rfkid_1"
}
},
{
"filter": {
"category_id": "2",
"colors": "blue"
},
"widget": {
"rfkid": "rfkid_4"
}
}
]
}