Method: query.suggest

Provides suggestions for autocompleting the query.

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(RequestOptions)
  },
  "query": string,
  "dataSourceRestrictions": [
    {
      object(DataSourceRestriction)
    }
  ]
}
Fields
requestOptions

object(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(DataSourceRestriction)

The sources to use for suggestions. If not specified, all data sources from the current search application are used. Suggestions are based on Gmail titles. Suggestions from third party sources are not available.

Response body

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

Response of the suggest API.

JSON representation
{
  "suggestResults": [
    {
      object(SuggestResult)
    }
  ]
}
Fields
suggestResults[]

object(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 OAuth 2.0 Overview.

SuggestResult

One suggestion result.

JSON representation
{
  "suggestedQuery": string,
  "source": {
    object(Source)
  },

  // Union field suggestion can be only one of the following:
  "querySuggestion": {
    object(QuerySuggestion)
  },
  "peopleSuggestion": {
    object(PeopleSuggestion)
  }
  // End of list of possible types for union field suggestion.
}
Fields
suggestedQuery

string

The suggested query that will be used for search, when the user clicks on the suggestion

source

object(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(QuerySuggestion)

This field will be present if the suggested query is a word/phrase completion.

peopleSuggestion

object(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(Person)
  }
}
Fields
person

object(Person)

Suggested person. All fields of the person object might not be populated.

Try it!

Send feedback about...

Cloud Search
Cloud Search