The content request object
Add a content JSON object in a Sitecore Discover Search and Recommendation request to specify the type of content you want to see in the search results. To further customize results, you can specify the maximum number of results, sorting type, and fields displayed for each <content_type> in the request.
The following shows the structure of the content object in a request:
{
"content": {
"<content_type>": {
"max": 10,
"sort": {
"type": "text",
"order": "asc"
},
"get_fields": false,
"field": {
"value": [
"<content_field>"
]
}
}
}
}Keys
The following table describes the key that the content object contains.
|
Key |
Type |
Description |
Value |
|---|---|---|---|
|
|
Required. Type of content that can be queried one at a time or multiple instances at a time. Each content type requires a feed or another data source. The only out-of-the-box Default: |
|
Content type object
The following table describes the keys in the content type object:
|
Key |
Type |
Description |
|---|---|---|
|
|
integer |
Optional. Limits the number of results of the content returned per page. Default: |
|
|
Optional. Determines the sort order of the Example: RequestResponse | |
|
|
Boolean |
Optional. If you set this to Default: |
|
|
array of strings |
Optional The available |
Sort object
The following table describes the keys in the sort object:
|
Key |
Type |
Description |
Value |
|---|---|---|---|
|
|
string |
Required. Whether you want to sort content alphabetically or by the number of items that have this value. For example, a search result has five red and four blue items. If you specify the sort |
|
|
|
string |
Required. Whether you want to sort content in an ascending or descending order. |
|
Related keys
The following table describes the keys related to the content object:
|
Key |
Type |
Description |
|---|---|---|
|
|
integer |
Optional. Total number of the items to be returned for all Note The Default: |
|
|
integer |
Optional. Page number to be returned. The page contains a maximum of Note The Default: Example: A request for |
Example
The following code shows a request to get the name and price of 10 products:
{
"n_item": 10,
"content": {
"product": {
"field": {
"value": [
"price"
]
}
}
}
}