query

POST /v1/query/search

Changed on

The Cloud Search Query API provides the search method, which returns the most relevant results from a user query. The results can come from Google Workspace apps, such as Gmail or Google Drive, or they can come from data that you have indexed from a third party. 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.

Request

  • Base URL
    https://cloudsearch.googleapis.com
  • Auth
    • OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/cloud_search
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/cloud_search
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/cloud_search.query
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/cloud_search.query

Query parameters

$.xgafv, '1' | '2'

V1 error format.

access_token, string

OAuth access token.

alt, 'json' | 'media' | 'proto'

Data format for response.

callback, string

JSONP

fields, string

Selector specifying which fields to include in a partial response.

key, string

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_token, string

OAuth 2.0 token for the current user.

prettyPrint, boolean

Returns response with indentations and line breaks.

quotaUser, string

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

uploadType, string

Legacy upload protocol for media (e.g. "media", "multipart").

upload_protocol, string

Upload protocol for media (e.g. "raw", "multipart").

Request body

SearchRequest required

The search API request. NEXT ID: 26

contextAttributes, ContextAttribute[]

Context attributes for the request which will be used to adjust ranking of search results. The maximum number of elements is 10.

dataSourceRestrictions, DataSourceRestriction[]

The sources to use for querying. If not specified, all data sources from the current search application are used.

facetOptions, FacetOptions[]
pageSize, integer

Maximum number of search results to return in one page. Valid values are between 1 and 100, inclusive. Default value is 10. Minimum value is 50 when results beyond 2000 are requested.

query, string

The raw query string. See supported search operators in the Narrow your search with operators

queryInterpretationOptions, QueryInterpretationOptions

Options to interpret user query.

requestOptions, RequestOptions

Shared request options for all RPC methods.

sortOptions, SortOptions
start, integer

Starting index of the results.

Response

Successful response

SearchResponse required

The search API response. NEXT ID: 22

debugInfo, ResponseDebugInfo

Debugging information about the response.

errorInfo, ErrorInfo

Error information about the response.

facetResults, FacetResult[]

Repeated facet results.

hasMoreResults, boolean

Whether there are more search results matching the query.

queryInterpretation, QueryInterpretation
resultCountEstimate, string int64

The estimated result count for this query.

resultCountExact, string int64

The exact result count for this query.

resultCounts, ResultCounts

Result count information

results, SearchResult[]

Results from a search query.

spellResults, SpellResult[]

Suggested spelling for the query.

structuredResults, StructuredResult[]

Structured results for the user query. These results are not counted against the page_size.

Changes

    • info

      the security scope https://www.googleapis.com/auth/cloud_search was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud_search was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/cloud_search.query was removed from the endpoint's security scheme Oauth2

    1 more change in this revision