- HTTP request
- Request body
- Response body
- Authorization Scopes
- SuggestResult
- QuerySuggestion
- PeopleSuggestion
- Try it!
Provides suggestions for autocompleting the query.
Note: This API requires a standard end user account to execute. A service account can't perform Query API requests directly; to use a service account to perform queries, set up Google Workspace domain-wide delegation of authority.
HTTP request
POST https://cloudsearch.googleapis.com/v1/query/suggest
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "requestOptions": { object ( |
Fields | |
---|---|
requestOptions |
Request options, such as the search application and user timezone. |
query |
Partial query for which autocomplete suggestions will be shown. For example, if the query is "sea", then the server might return "season", "search", "seagull" and so on. |
dataSourceRestrictions[] |
The sources to use for suggestions. If not specified, the data sources are taken from the current search application. NOTE: Suggestions are only supported for the following sources:
|
Response body
If successful, the response body contains data with the following structure:
Response of the suggest API.
JSON representation |
---|
{
"suggestResults": [
{
object ( |
Fields | |
---|---|
suggestResults[] |
List of suggestions. |
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud_search.query
https://www.googleapis.com/auth/cloud_search
For more information, see the Authorization guide.
SuggestResult
One suggestion result.
JSON representation |
---|
{ "suggestedQuery": string, "source": { object ( |
Fields | |
---|---|
suggestedQuery |
The suggested query that will be used for search, when the user clicks on the suggestion |
source |
The source of the suggestion. |
Union field suggestion . Contains additional metadata about the suggested query. It also indicates the type of the suggested query. For e.g. if PeopleSuggestion is present, it indicates that suggested_query is a person suggestion. suggestion can be only one of the following: |
|
querySuggestion |
This field will be present if the suggested query is a word/phrase completion. |
peopleSuggestion |
This is present when the suggestion indicates a person. It contains more information about the person - like their email ID, name etc. |
QuerySuggestion
This field does not contain anything as of now and is just used as an indicator that the suggest result was a phrase completion.
PeopleSuggestion
This field contains information about the person being suggested.
JSON representation |
---|
{
"person": {
object ( |
Fields | |
---|---|
person |
Suggested person. All fields of the person object might not be populated. |