Method: query.suggest
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
क्वेरी को अपने-आप पूरा करने के लिए सुझाव देता है.
ध्यान दें: इस एपीआई को चलाने के लिए, स्टैंडर्ड असली उपयोगकर्ता खाते की ज़रूरत होती है. सेवा खाता, सीधे तौर पर क्वेरी एपीआई के अनुरोधों को पूरा नहीं कर सकता. क्वेरी करने के लिए, सेवा खाते का इस्तेमाल करने के लिए, Google Workspace के डोमेन के लिए, अधिकार देने की सुविधा सेट अप करें.
एचटीटीपी अनुरोध
POST https://cloudsearch.googleapis.com/v1/query/suggest
यूआरएल में gRPC ट्रांसकोडिंग सिंटैक्स का इस्तेमाल किया गया है.
अनुरोध का मुख्य भाग
अनुरोध के मुख्य भाग में नीचे दिए गए स्ट्रक्चर वाला डेटा होता है:
फ़ील्ड |
requestOptions |
object (RequestOptions )
अनुरोध के विकल्प, जैसे कि खोज ऐप्लिकेशन और उपयोगकर्ता का टाइमज़ोन.
|
query |
string
वह क्वेरी जिसे ऑटोकंप्लीट की सुविधा की मदद से पूरा किया जा सकता है. उदाहरण के लिए, अगर क्वेरी "sea" है, तो सर्वर "season", "search", "seagull" वगैरह दिखा सकता है.
|
dataSourceRestrictions[] |
object (DataSourceRestriction )
सुझावों के लिए इस्तेमाल किए जाने वाले सोर्स. अगर डेटा सोर्स की जानकारी नहीं दी जाती है, तो मौजूदा सर्च ऐप्लिकेशन से डेटा सोर्स लिए जाते हैं. ध्यान दें: सुझाव सिर्फ़ इन सोर्स के लिए काम करते हैं:
- तीसरे पक्ष के डेटा सोर्स
- PredefinedSource.PERSON
- PredefinedSource.GOOGLE_DRIVE
|
जवाब का मुख्य भाग
suggest API का रिस्पॉन्स.
अगर एपीआई सही से जुड़ जाता है, ताे जवाब के मुख्य भाग में नीचे दिए गए स्ट्रक्चर शामिल होता है.
JSON के काेड में दिखाना |
{
"suggestResults": [
{
object (SuggestResult )
}
]
} |
फ़ील्ड |
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 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया."],[],[],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. |"]]