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.

KeyType/default valueDescriptionValue
suggestion_type>Suggestion type objectRequired.Contains the specific algorithm for generating suggestions.autocomplete (Default)keyphrasecategorytrending_categoryrecent

Suggestion type object

The following table describes the keys in the suggestion type object:

KeyTypeDescription
maxintegerOptional.The maximum number of suggestions.Default: 5.
in_contentarrayOptional.Contains the specific <content_type> for the requested suggestion.NoteThere is no default value for in_content because there is no limitation on the <content_type> .

Suggestion types

The following are different types or algorithms for generating the suggestion:

Suggestion typeDescriptionValue
keyphraseA mix of suggestions.type_correctionquery_expansionrelated_search
categoryCategories that contain the search term.n/a
trending_categoryA category that is trending now.n/a
recentRecent search history.n/a

The following table describes the key related to theĀ suggestion object.

KeyTypeDescription
request_forarrayOptional.

Contains the request parameters. You can request any field in the request data or request all fields using the wild card all.

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"
		}]
         }
       }
    }
}
If you have suggestions for improving this article, let us know!