The query request object

You can add a query JSON object in a Sitecore Discover Search and Recommendation request. The object contains the query string for each type of query. The value of each <query_type> is a value object. The value of the value object is a list containing either a string or a list of strings.

If a query does not return any results, Sitecore Discover runs another query using the top suggestion from the original query.

The following shows the basic structure of the query object in a request:

RequestResponse
{
    "query": {
	"<query_type>": {
           "value": [<query_string>]
	}
    }
}

Keys

The following table describes the keys that the query object contains.

Key

Type

Description

Value

<query_type>

Query type object

Optional.

Type of data that you can use to search. Keyphrase data is a general text search.

  • keyphrase

Query type object

The following table describes the key in the querytype object:

Key

Type

Description

<query_type>.value

array

Required.

Contains a string or a list of strings with the <query_string> values.

The following table describes the key related to the query request.

Key

Type

Description

exact_match

Boolean

Use exact_match to control the search behavior by matching the query keyphrase.

If true, Discover searches only using the exact keyphrase.

Default: false

Example

The following are examples of query objects using the keyphrase red in full and short representations.

Full representation request:

RequestResponse
{
    "query": {
	"keyphrase": {
		"value": ["red"]
    	 }
    },
     "exact_match": true
}

Short representation request:

RequestResponse
{
    "query": {
	"keyphrase": "red"
    },
    "exact_match": true
}

Do you have some feedback for us?

If you have suggestions for improving this article,