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:

RequestResponse
{
  "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

suggestion_type>

Suggestion type object

Required.

Contains the specific algorithm for generating suggestions.

  • autocomplete (Default)

  • keyphrase

  • category

  • trending_category

  • recent

Suggestion type object

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

Key

Type

Description

max

integer

Optional.

The maximum number of suggestions.

Default: 5.

in_content

array

Optional.

Contains the specific <content_type> for the requested suggestion.

Note

There 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 type

Description

Value

keyphrase

A mix of suggestions.

  • type_correction

  • query_expansion

  • related_search

category

Categories that contain the search term.

n/a

trending_category

A category that is trending now.

n/a

recent

Recent search history.

n/a

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

Key

Type

Description

request_for

array

Optional.

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:

RequestResponse
{
   "suggestion": {
      "recent": {
	"max": 10,
	"in_content": {
	     "value": [{
		"type": "product"
		}]
         }
       }
    }
}

Do you have some feedback for us?

If you have suggestions for improving this article,