The suggestion request object
You can add a suggestion JSON object in a Sitecore Discover Search and Recommendation request. The suggestion object contains the different types of suggestions you can use to autocomplete your query and display predictive search results. Each <suggestion_type> provides a specific algorithm to generate suggestions.
The following shows the structure of the suggestion object in a request:
{
"suggestion": {
"<suggestion_type>": {
"max": 5,
"in_content": {
"value": [{
"type": "<content_type>"
}]
}
}
}
}Keys
The following table describes the keys that the suggestion object contains.
|
Key |
Type/default value |
Description |
Value |
|---|---|---|---|
|
|
Required. Contains the specific algorithm for generating suggestions. |
|
Suggestion type object
The following table describes the keys in the suggestion type object:
|
Key |
Type |
Description |
|---|---|---|
|
|
integer |
Optional. The maximum number of suggestions. Default: |
|
|
array |
Optional. Contains the specific Note There is no default value for |
Suggestion types
The following are different types or algorithms for generating the suggestion:
|
Suggestion type |
Description |
Value |
|---|---|---|
|
|
A mix of suggestions. |
|
|
|
Categories that contain the search term. |
n/a |
|
|
A category that is trending now. |
n/a |
|
|
Recent search history. |
n/a |
Related key
The following table describes the key related to the suggestion object.
|
Key |
Type |
Description |
|---|---|---|
|
|
array |
Optional. Contains the request parameters. You can request any field in the request data or request all fields using the wild card |
Example
The following shows an example of a request to get the user's last ten search queries in the product content type:
{
"suggestion": {
"recent": {
"max": 10,
"in_content": {
"value": [{
"type": "product"
}]
}
}
}
}