Method: query.suggest
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تقدّم اقتراحات للإكمال التلقائي لطلب البحث.
ملاحظة: تتطلّب واجهة برمجة التطبيقات هذه حساب مستخدم نهائي عادي لتنفيذها. لا يمكن لحساب الخدمة تنفيذ طلبات واجهة برمجة التطبيقات لطلبات البحث مباشرةً. لاستخدام حساب خدمة لإجراء طلبات بحث، عليك إعداد تفويض السلطة على مستوى نطاق Google Workspace.
طلب HTTP
POST https://cloudsearch.googleapis.com/v1/query/suggest
يستخدِم عنوان URL بنية تحويل ترميز gRPC.
نص الطلب
يحتوي نص الطلب على بيانات بالبنية التالية:
الحقول |
requestOptions |
object (RequestOptions )
خيارات الطلب، مثل تطبيق البحث والمنطقة الزمنية للمستخدم
|
query |
string
طلب بحث جزئي سيتم عرض اقتراحات الإكمال التلقائي له. على سبيل المثال، إذا كان طلب البحث هو "البحر"، قد يعرض الخادم "الموسم" و"البحث" و"طيور النورس" وما إلى ذلك.
|
dataSourceRestrictions[] |
object (DataSourceRestriction )
المصادر التي سيتم استخدامها لاقتراحات. في حال عدم تحديدها، يتم الحصول على مصادر البيانات من طلب البحث الحالي. ملاحظة: لا تتوفّر الاقتراحات إلا للمصادر التالية:
- مصادر البيانات التابعة لجهات خارجية
- PredefinedSource.PERSON
- PredefinedSource.GOOGLE_DRIVE
|
نص الاستجابة
استجابة واجهة برمجة التطبيقات المقترَحة
إذا كانت الاستجابة ناجحة، سيحتوي نص الاستجابة على بيانات بالبنية التالية:
الحقول |
suggestResults[] |
object (SuggestResult )
قائمة بالاقتراحات
|
نطاقات التفويض
يتطلب أحد نطاقات OAuth التالية:
https://www.googleapis.com/auth/cloud_search.query
https://www.googleapis.com/auth/cloud_search
لمزيد من المعلومات، يمكنك الاطّلاع على دليل التفويض.
SuggestResult
تمثيل JSON |
{
"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 .
} |
الحقول |
suggestedQuery |
string
طلب البحث المقترَح الذي سيتم استخدامه للبحث عندما ينقر المستخدم على الاقتراح
|
source |
object (Source )
مصدر الاقتراح
|
حقل الربط suggestion يحتوي على بيانات وصفية إضافية عن طلب البحث المقترَح. ويشير أيضًا إلى نوع طلب البحث المقترَح. على سبيل المثال، إذا كان PeopleSuggestion متوفّرًا، يعني ذلك أنّ suggested_query هو اقتراح لمستخدم. يمكن أن يكون suggestion واحدًا فقط مما يلي: |
querySuggestion |
object (QuerySuggestion )
سيظهر هذا الحقل إذا كان الطلب المقترَح عبارة عن كلمة أو عبارة مكتملة.
|
peopleSuggestion |
object (PeopleSuggestion )
يظهر هذا الرمز عندما يشير الاقتراح إلى مستخدم. يحتوي على مزيد من المعلومات عن المستخدم، مثل رقم تعريف بريده الإلكتروني واسمه وما إلى ذلك.
|
QuerySuggestion
لا يحتوي هذا النوع على أي حقول.
لا يحتوي هذا الحقل على أيّ شيء حتى الآن، ويتم استخدامه فقط كمؤشر على أنّ النتيجة المقترَحة كانت عبارة عن إكمال عبارة.
PeopleSuggestion
يحتوي هذا الحقل على معلومات عن المستخدم المقترَح.
تمثيل JSON |
{
"person": {
object (Person )
}
} |
الحقول |
person |
object (Person )
شخص مقترَح قد لا يتم تعبئة جميع حقول عنصر الشخص.
|
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Method: query.suggest\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 - [JSON representation](#body.SuggestResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [SuggestResult](#SuggestResult)\n - [JSON representation](#SuggestResult.SCHEMA_REPRESENTATION)\n- [QuerySuggestion](#QuerySuggestion)\n- [PeopleSuggestion](#PeopleSuggestion)\n - [JSON representation](#PeopleSuggestion.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nProvides suggestions for autocompleting the query.\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/suggest`\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, \"dataSourceRestrictions\": [ { object (/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#DataSourceRestriction) } ] } ``` |\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` 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. |\n| `dataSourceRestrictions[]` | `object (`[DataSourceRestriction](/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 |\n\n### Response body\n\nResponse of the suggest API.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"suggestResults\": [ { object (/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult) } ] } ``` |\n\n| Fields ||\n|--------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `suggestResults[]` | `object (`[SuggestResult](/workspace/cloud-search/docs/reference/rest/v1/query/suggest#SuggestResult)`)` List of suggestions. |\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).\n\nSuggestResult\n-------------\n\nOne suggestion result.\n\n| JSON representation |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"suggestedQuery\": string, \"source\": { object (/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#Source) }, // Union field `suggestion` can be only one of the following: \"querySuggestion\": { object (/workspace/cloud-search/docs/reference/rest/v1/query/suggest#QuerySuggestion) }, \"peopleSuggestion\": { object (/workspace/cloud-search/docs/reference/rest/v1/query/suggest#PeopleSuggestion) } // End of list of possible types for union field `suggestion`. } ``` |\n\n| Fields ||\n|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `suggestedQuery` | `string` The suggested query that will be used for search, when the user clicks on the suggestion |\n| `source` | `object (`[Source](/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#Source)`)` The source of the suggestion. |\n| 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: ||\n| `querySuggestion` | `object (`[QuerySuggestion](/workspace/cloud-search/docs/reference/rest/v1/query/suggest#QuerySuggestion)`)` This field will be present if the suggested query is a word/phrase completion. |\n| `peopleSuggestion` | `object (`[PeopleSuggestion](/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. |\n\nQuerySuggestion\n---------------\n\nThis type has no fields.\nThis field does not contain anything as of now and is just used as an indicator that the suggest result was a phrase completion.\n\nPeopleSuggestion\n----------------\n\nThis field contains information about the person being suggested.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------|\n| ``` { \"person\": { object (/workspace/cloud-search/docs/reference/rest/v1/Person) } } ``` |\n\n| Fields ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `person` | `object (`[Person](/workspace/cloud-search/docs/reference/rest/v1/Person)`)` Suggested person. All fields of the person object might not be populated. |"]]