# Method: query.suggest

- [HTTP request](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.request_body)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.response_body)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.SuggestResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#body.aspect)
- [SuggestResult](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult.SCHEMA_REPRESENTATION)
- [QuerySuggestion](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#QuerySuggestion)
- [PeopleSuggestion](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#PeopleSuggestion)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#PeopleSuggestion.SCHEMA_REPRESENTATION)
- [Try it!](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#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](https://developers.google.com/workspace/cloud-search/docs/guides/delegation/).

### HTTP request

`POST https://cloudsearch.googleapis.com/v1/query/suggest`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "requestOptions": { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/RequestOptions`) }, "query": string, "dataSourceRestrictions": [ { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#DataSourceRestriction`) } ] } ``` |

| Fields ||
|---|---|
| `requestOptions` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/RequestOptions`)`` Request options, such as the search application and user timezone. |
| `query` | `string` 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[]` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#DataSourceRestriction`)`` 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: - Third-party data sources - PredefinedSource.PERSON - PredefinedSource.GOOGLE_DRIVE |

### Response body

Response of the suggest API.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "suggestResults": [ { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult`) } ] } ``` |

| Fields ||
|---|---|
| `suggestResults[]` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult`)`` 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](https://developers.google.com/workspace/guides/configure-oauth-consent).

## SuggestResult

One suggestion result.

| JSON representation |
|---|
| ``` { "suggestedQuery": string, "source": { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#Source`) }, "querySuggestion": { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#QuerySuggestion`) }, "peopleSuggestion": { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#PeopleSuggestion`) } } ``` |

| Fields ||
|---|---|
| `suggestedQuery` | `string` The suggested query that will be used for search, when the user clicks on the suggestion |
| `source` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#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` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#QuerySuggestion`)`` This field will be present if the suggested query is a word/phrase completion. |
| `peopleSuggestion` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/query/suggest#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 type has no fields.
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 (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/Person`) } } ``` |

| Fields ||
|---|---|
| `person` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/Person`)`` Suggested person. All fields of the person object might not be populated. |