Mantieni tutto organizzato con le raccolte Salva e classifica i contenuti in base alle tue preferenze.
Devi configurare l'accesso all'API Google Cloud Search prima di poterla utilizzare direttamente o tramite un SDK. Questo documento descrive i passaggi necessari per utilizzare l'API REST dell'API Google Cloud Search.
1. Crea un progetto API
Per abilitare l'API, devi prima creare un progetto Google Cloud. Questo progetto è la base per creare, abilitare e utilizzare tutti i servizi Google Cloud, tra cui gestione delle API, attivazione della fatturazione, aggiunta e rimozione di collaboratori e gestione delle autorizzazioni.
Nella parte superiore della pagina, fai clic su arrow_drop_down a destra di "Console Google Cloud". Viene visualizzata una finestra di dialogo che elenca i progetti attuali.
Fai clic su NUOVO PROGETTO. Viene visualizzata la schermata "Nuovo progetto".
Inserisci un nome per il progetto nel campo Nome progetto.
(Facoltativo) Fai clic su Modifica per modificare l'ID progetto. L'ID progetto non può essere modificato dopo la creazione del progetto, quindi scegli un ID che soddisfi le tue esigenze per tutta la durata del progetto.
Per sfogliare le posizioni del progetto, fai clic su SFOGLIA.
Fai clic su una posizione per il progetto e poi su Seleziona.
Fai clic su Crea. La console passa alla pagina Dashboard. Il progetto viene creato in pochi minuti.
Per ulteriori informazioni sulla creazione e sulla gestione dei progetti, consulta la pagina Creare e gestire progetti.
2. Abilita l'API
Devi abilitare l'API Google Cloud Search e creare un service account per ottenere le credenziali.
Per assicurarti di trovarti nel progetto appena creato, fai clic sull'icona arrow_drop_down a destra del banner della console Google Cloud e seleziona il progetto appena creato.
Fai clic su ABILITA API E SERVIZI. Viene visualizzata la pagina "Ti diamo il benvenuto nella libreria di API".
Nella console Google Cloud, fai clic su Credenziali nel riquadro di navigazione a sinistra. Viene visualizzata la pagina Credenziali.
Nell'elenco a discesa Crea credenziali, seleziona Service account. Viene visualizzata la pagina "Crea service account".
Inserisci un nome nel campo Nome account di servizio.
(Facoltativo) Modifica l'ID service account.
Fai clic su Crea. Viene visualizzata la schermata "Autorizzazioni account di servizio".
Fai clic su Continua. Viene visualizzata una schermata "Concedi agli utenti l'accesso a questo service account".
Fai clic su CREA CHIAVE e poi su Fine. Viene visualizzata la finestra di dialogo "Chiave privata salvata nel computer" e una copia della chiave privata viene scaricata sul computer.
Nella console Google Cloud, seleziona il progetto che hai creato nella parte superiore della pagina.
Fai clic sul menu di navigazione a sinistra del banner della console Google Cloud.
Fai clic su IAM e amministrazione > Service account.
Nell'elenco, in "ID service account", prendi nota dell'indirizzo email generato che identifica il service account che hai configurato. Questo indirizzo email viene utilizzato quando aggiungi un'origine dati a Cloud Search.
5. Inizializzare l'assistenza di terze parti
Prima di poter chiamare altre API Cloud Search, devi inizializzare il supporto di terze parti per Google Cloud Search.
Per inizializzare il supporto di terze parti per Cloud Search:
Il progetto della piattaforma Cloud Search contiene le credenziali del service account. Tuttavia, per inizializzare il supporto di terze parti, devi creare le credenziali dell'applicazione web. Per istruzioni su come creare le credenziali dell'applicazione web, consulta Creare le credenziali. Al termine di questo passaggio, dovresti avere un file con l'ID client e il client secret.
Fai clic su Impostazioni e seleziona Utilizza le tue credenziali di autenticazione.
Inserisci l'ID client e il client secret del passaggio 1.
Fai clic su Chiudi.
Nel campo degli ambiti, digita https://www.googleapis.com/auth/cloud_search.settings e fai clic su Autorizza. OAuth 2 Playground restituisce un codice di autorizzazione.
Fai clic su Exchange authorization code for tokens (Scambio codice di autorizzazione per i token). Viene restituito un token.
Per inizializzare il supporto di terze parti per Cloud Search, utilizza il seguente comando curl. Assicurati di sostituire [YOUR_ACCESS_TOKEN] con il token ottenuto nel passaggio 2.
Se prevedi di utilizzare Google Cloud Search con un repository di dati non Google, come Microsoft® SharePoint®, devi creare un'origine dati. Per istruzioni su come aggiungere un'origine dati, consulta Aggiungere un'origine dati per la ricerca.
Una volta configurata l'origine dati, puoi creare e registrare uno schema per identificare il modo in cui Google Cloud Search deve rappresentare i dati nel repository.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-04 UTC."],[],[],null,["You must configure access to the Google Cloud Search API before you can\nuse this API either directly or through an SDK. This document\ncovers the steps required to use the Google Cloud Search API REST API.\n\n1. Create an API project\n\nTo enable the API, you must first create an Google Cloud project. This\nproject forms the basis for creating, enabling, and using all Google Cloud\nservices, including managing APIs, enabling billing, adding and\nremoving collaborators, and managing permissions.\n\n1. Open the [Google Cloud console](https://console.cloud.google.com/apis/dashboard).\n\n2. At the top of the page, click\n arrow_drop_down\n to the right of \"Google Cloud Console.\" A dialog listing current projects\n appears.\n\n3. Click **NEW PROJECT**. The \"New Project\" screen appears.\n\n4. Enter a project name in the **Project Name** field.\n\n5. (optional) Click **Edit** to edit the Project ID. The project ID can't be\n changed after the project is created, so choose an\n ID that meets your needs for the lifetime of the project.\n\n6. To browse locations for the project, click **BROWSE**.\n\n7. Click on a location for your project and click **Select**.\n\n8. Click **Create**. The console navigates to the Dashboard page. The project\n is created within a few minutes.\n\nFor further information on creating and managing projects, refer to\n[Creating and Managing Projects](https://support.google.com/cloud#topic=6158848).\n\n2. Enable the API\n\nYou need to enable the Google Cloud Search API and create a service account to\nobtain credentials.\n\n1. To ensure you are on the newly created project, click the arrow_drop_down icon to the right of the Google Cloud console banner and select your newly-created project.\n2. Click **ENABLE APIS AND SERVICES**. The \"Welcome to API Library\" page appears.\n3. Navigate to the [Google Cloud Search API](https://console.cloud.google.com/apis/api/cloudsearch.googleapis.com).\n4. Click **Enable**. The \"Overview\" page appears.\n\nFor further information on enabling and disabling APIs, refer to\n[Manage APIs in the Google Cloud console](https://support.google.com/cloud/answer/6326510)\n| **Note:** Different Cloud Search APIs require different accounts to execute (admin, service, and user). For further information, refer to the [reference documentation](/workspace/cloud-search/docs/reference) for the method you want to call.\n\n3. Create service account credentials\n\n1. In the [Google Cloud console](https://console.cloud.google.com/apis/library), click **Credentials** in the left navigation. The Credential page appears.\n2. From the **Create credentials** drop-down list, select **Service account**. The \"Create service account\" page appears.\n3. Enter a name in the **Service account name** field.\n4. (optional) Edit the service account ID.\n5. Click **Create**. A \"Service account permissions\" screen appears.\n6. Click **Continue**. A \"Grant users access to this service account\" screen appears.\n7. Click **CREATE KEY** and click **Done**. A \"Private key saved to your computer\" dialog appears and a copy of the private key downloads to your computer.\n8. Click **Close**.\n\nFor further information on service accounts, refer to\n[Service accounts, web applications, and installed applications](https://support.google.com/cloud/answer/6158849#serviceaccounts)\n\n4. Identify email address\n\n1. From the [Google Cloud console](https://console.cloud.google.com/apis/dashboard), select the project you created at the top of the page.\n2. Click the Navigation menu to the left of the Google Cloud console banner.\n3. Click **IAM and Admin** \\\u003e **Service accounts**.\n4. In the list, under \"Service account ID,\" make note of the generated email address that identifies the service account you configured. This email address is used when adding a data source to Cloud Search.\n\n5. Initialize third-party support\n\nBefore you can call any other Cloud Search APIs, you must initialize third-party\nsupport for Google Cloud Search.\n| **Note:** If you successfully executed the Cloud Search tutorial, you have already initialized third-party support for Cloud Search and can skip this step.\n\nTo initialize third-party support for Cloud Search:\n\n1. Your Cloud Search platform project contains service account credentials.\n However, for the sake of initializing third-party support, you must create web\n application credentials. For instructions on how to create web application\n credentials, refer to\n [Create credentials](/workspace/guides/create-credentials).\n Upon completing this step, you should have a client ID and client secret file.\n\n2. Use\n [Google's OAuth 2 playground](https://developers.google.com/oauthplayground/)\n to obtain an access token:\n\n 1. Click settings and check **User your own auth credentials**.\n 2. Enter the client ID and client secret from step 1.\n 3. Click **Close**.\n 4. In the scopes field, type `https://www.googleapis.com/auth/cloud_search.settings` and click **Authorize**. The OAuth 2 playground returns an authorization code.\n 5. Click **Exchange authorization code for tokens**. A token is returned.\n3. To initialize third-party support for Cloud Search, use the following curl\n command. Be sure to substitute `[YOUR_ACCESS_TOKEN]` with the token obtained in\n step 2.\n\n curl --request POST \\\n 'https://cloudsearch.googleapis.com/v1:initializeCustomer' \\\n --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \\\n --header 'Accept: application/json' \\\n --header 'Content-Type: application/json' \\\n --data '{}' \\\n --compressed\n\n If successful, the response body contains an instance of\n [`operation`](/workspace/cloud-search/docs/reference/rest/v1/operations#Operation). For\n example: \n\n {\n name: \"operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY\"\n }\n\n If unsuccessful, contact Cloud Search support.\n4. Use [operations.get](/workspace/cloud-search/docs/reference/rest/v1/operations/get) to verify that\n third-party support is initialized:\n\n curl \\\n 'https://cloudsearch.googleapis.com/v1/operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY?key=\n [YOUR_API_KEY]' \\\n --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \\\n --header 'Accept: application/json' \\\n --compressed\n\n When the third-party initialization is complete, it contains the\n field `done` set to `true`. For example: \n\n {\n name: \"operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY\"\n done: true\n }\n\nNext Steps\n\nHere are few next steps you might take:\n\n1. If you plan on using Google Cloud Search with a non-Google data repository,\n such as Microsoft® SharePoint®, you\n must create a data source. For instructions on\n adding a data source, refer to\n [Add a data source to search](https://support.google.com/a/answer/7056471).\n\n2. Once you set up your data source, you can\n [create and register schema](/workspace/cloud-search/docs/guides/schema-guide) to identify\n how Google Cloud Search should represent the data in the repository."]]