Method: query.search
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
API kueri Cloud Search menyediakan metode penelusuran, yang menampilkan hasil yang paling relevan dari kueri pengguna. Hasilnya dapat berasal dari aplikasi Google Workspace, seperti Gmail atau Google Drive, atau dapat berasal dari data yang telah Anda indeks dari pihak ketiga.
Catatan: API ini memerlukan akun pengguna akhir standar untuk dieksekusi. Akun layanan tidak dapat menjalankan permintaan API kueri secara langsung; untuk menggunakan akun layanan guna menjalankan kueri, siapkan delegasi otorisasi seluruh domain Google Workspace.
Permintaan HTTP
POST https://cloudsearch.googleapis.com/v1/query/search
URL menggunakan sintaksis gRPC Transcoding.
Isi permintaan
Isi permintaan memuat data dengan struktur berikut:
Kolom |
requestOptions |
object (RequestOptions )
Opsi permintaan, seperti aplikasi penelusuran dan zona waktu pengguna.
|
query |
string
String kueri mentah. Lihat operator penelusuran yang didukung di Mempersempit penelusuran dengan operator
|
pageSize |
integer
Jumlah maksimum hasil penelusuran yang akan ditampilkan di satu halaman. Nilai yang valid adalah antara 1 dan 100, inklusif. Nilai defaultnya adalah 10. Nilai minimum adalah 50 jika hasil di luar 2.000 diminta.
|
start |
integer
Indeks awal hasil.
|
dataSourceRestrictions[] |
object (DataSourceRestriction )
Sumber yang akan digunakan untuk membuat kueri. Jika tidak ditentukan, semua sumber data dari aplikasi penelusuran saat ini akan digunakan.
|
facetOptions[] |
object (FacetOptions )
|
sortOptions |
object (SortOptions )
Opsi untuk mengurutkan hasil penelusuran
|
queryInterpretationOptions |
object (QueryInterpretationOptions )
opsi untuk menafsirkan kueri pengguna.
|
contextAttributes[] |
object (ContextAttribute )
Atribut konteks untuk permintaan yang akan digunakan untuk menyesuaikan peringkat hasil penelusuran. Jumlah maksimum elemen adalah 10.
|
Isi respons
Jika berhasil, isi respons memuat instance SearchResponse
.
Cakupan otorisasi
Memerlukan salah satu cakupan OAuth berikut:
https://www.googleapis.com/auth/cloud_search.query
https://www.googleapis.com/auth/cloud_search
Untuk mengetahui informasi selengkapnya, lihat Panduan otorisasi.
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-25 UTC.
[null,null,["Terakhir diperbarui pada 2025-07-25 UTC."],[],[],null,["# Method: query.search\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nThe 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.\n\n**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/).\n\n### HTTP request\n\n`POST https://cloudsearch.googleapis.com/v1/query/search`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"requestOptions\": { object (/workspace/cloud-search/docs/reference/rest/v1/RequestOptions) }, \"query\": string, \"pageSize\": integer, \"start\": integer, \"dataSourceRestrictions\": [ { object (/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#DataSourceRestriction) } ], \"facetOptions\": [ { object (/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#FacetOptions) } ], \"sortOptions\": { object (/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#SortOptions) }, \"queryInterpretationOptions\": { object (/workspace/cloud-search/docs/reference/rest/v1/QueryInterpretationOptions) }, \"contextAttributes\": [ { object (/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ContextAttribute) } ] } ``` |\n\n| Fields ||\n|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `requestOptions` | `object (`[RequestOptions](/workspace/cloud-search/docs/reference/rest/v1/RequestOptions)`)` Request options, such as the search application and user timezone. |\n| `query` | `string` The raw query string. See supported search operators in the [Narrow your search with operators](https://support.google.com/cloudsearch/answer/6172299) |\n| `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. |\n| `start` | `integer` Starting index of the results. |\n| `dataSourceRestrictions[]` | `object (`[DataSourceRestriction](/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#DataSourceRestriction)`)` The sources to use for querying. If not specified, all data sources from the current search application are used. |\n| `facetOptions[]` | `object (`[FacetOptions](/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#FacetOptions)`)` |\n| `sortOptions` | `object (`[SortOptions](/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#SortOptions)`)` The options for sorting the search results |\n| `queryInterpretationOptions` | `object (`[QueryInterpretationOptions](/workspace/cloud-search/docs/reference/rest/v1/QueryInterpretationOptions)`)` options to interpret the user query. |\n| `contextAttributes[]` | `object (`[ContextAttribute](/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ContextAttribute)`)` Context attributes for the request which will be used to adjust ranking of search results. The maximum number of elements is 10. |\n\n### Response body\n\nIf successful, the response body contains an instance of [SearchResponse](/workspace/cloud-search/docs/reference/rest/v1/SearchResponse).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/cloud_search.query`\n- `https://www.googleapis.com/auth/cloud_search`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]