The suggestion response object
You get a response suggestion JSON object in a Sitecore Discover Search and Recommendation response if you send a suggestion object in the request. The response returns suggestions on your query based on different algorithms like autocomplete and query expansion.
The following shows the basic structure of the suggestion object in a response:
Keys
Depending on your request you might see some or all response keys.
The following table describes the keys in the suggestion response object:
| Parameters | Key | Description | Value |
|---|---|---|---|
| suggestion_type | Suggestion type object | Returns the specific algorithm used for generating the suggestion.NoteIf you added a suggestion object in your request, the response automatically returns an autocomplete suggestion regardless of the <suggestion_type> you requested. | keyphrasecategorytrending_categoryautocompleterecentSee suggestion types for details. |
Suggestion type object
The following table describes the keys in the suggestion_type object:
| Parameters | Key | Description | Suggestion types |
|---|---|---|---|
id | string | A unique ID that corresponds to the suggested value. You can use either the id or text for future query requests. | |
with_filter | object | You see this only if a specific filter is applied to the suggestion. | |
filter_id | string | Unique ID that corresponds to the filter value. | |
text | string | Display name of the filtered item. |
Suggestion types
The following are different types or algorithms for generating the suggestion
| <suggestion_type> | Description | Value |
|---|---|---|
| keyphrase | A mix of suggestions. | type_correction,autocomplete,query_expansionrelated_search |
| category | Categories that contain the searched term. | n/a |
| trending_category | A category that is trending now. | n/a |
| autocomplete | Completion of a keyphrase and predicting the possible search term based on earlier typed values. | n/a |
| recent | Recent search history. | n/a |
Related key
The following table describes the key related to theĀ suggestion response.
| Key | Type | Description |
|---|---|---|
| request_for | Array | Fields that Discover autocorrects.NoteThe response can return a modified keyphrase if you added both request_for and suggestion objects in your request. |
Example
The following code is an example of a response with a keyphrase suggestion using query_expansion:
The next example shows a response that returns an autocorrected keyphrase from the original misspelled search term. This applies if a suggestion object is added to the request.