Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Pour pouvoir utiliser l'API Google Cloud Search, vous devez configurer l'accès à celle-ci soit directement, soit via un SDK. Ce document décrit la procédure à suivre pour utiliser l'API REST Google Cloud Search.
1. Créer un projet d'API
Pour activer l'API, vous devez d'abord créer un projet Google Cloud. Ce projet constitue la base permettant de créer, d'activer et d'utiliser tous les services Google Cloud, entre autres pour gérer les API, activer la facturation, ajouter ou exclure des collaborateurs et gérer les autorisations.
En haut de la page, cliquez sur arrow_drop_down à droite de "Console Google Cloud". Une boîte de dialogue répertoriant les projets en cours apparaît.
Cliquez sur NOUVEAU PROJET. L'écran "Nouveau projet" s'affiche.
Saisissez un nom dans le champ Nom du projet.
(Facultatif) Cliquez sur Modifier pour modifier l'ID du projet. Vous ne pourrez plus modifier cet ID une fois le projet créé, donc choisissez un ID répondant à vos besoins pour toute la durée de vie du projet.
Pour parcourir les emplacements du projet, cliquez sur PARCOURIR.
Cliquez sur un emplacement pour votre projet, puis sur Sélectionner.
Cliquez sur Créer. La console vous redirige vers la page "Tableau de bord". Le projet est créé en quelques minutes.
Vous devez activer l'API Google Cloud Search et créer un compte de service pour obtenir des identifiants.
Pour vérifier que vous êtes bien dans le projet nouvellement créé, cliquez sur l'icône arrow_drop_down à droite de la bannière de la console Google Cloud, puis sélectionnez le projet que vous venez de créer.
Cliquez sur ACTIVER DES API ET DES SERVICES. La page "Bienvenue dans la bibliothèque d'API" s'affiche.
Dans la console Google Cloud, cliquez sur Identifiants dans le menu de navigation de gauche. La page "Identifiants" s'affiche.
Dans la liste déroulante Créer des identifiants, sélectionnez Compte de service. La page "Créer un compte de service" s'affiche.
Saisissez un nom dans le champ Nom du compte de service.
(Facultatif) Modifiez l'ID du compte de service.
Cliquez sur Créer. L'écran "Autorisations de compte de service" s'affiche.
Cliquez sur Continuer. L'écran "Autoriser les utilisateurs à accéder à ce compte de service" s'affiche.
Cliquez sur CRÉER UNE CLÉ, puis sur OK. Une boîte de dialogue "Clé privée enregistrée sur votre ordinateur" s'affiche et une copie de la clé privée est téléchargée sur votre ordinateur.
Dans la console Google Cloud, sélectionnez le projet que vous avez créé en haut de la page.
Cliquez sur le menu de navigation situé à gauche de la bannière de la console Google Cloud.
Cliquez sur IAM et administration > Comptes de service.
Dans la liste, sous "ID de compte de service", notez l'adresse e-mail générée qui identifie le compte de service que vous avez configuré. Cette adresse e-mail est utilisée lors de l'ajout d'une source de données à Cloud Search.
5. Initialiser la compatibilité tierce
Pour pouvoir appeler d'autres API Cloud Search, vous devez activer la compatibilité tierce pour Google Cloud Search.
Pour initialiser la compatibilité tierce avec Cloud Search :
Votre projet Cloud Search Platform contient les identifiants du compte de service.
Toutefois, pour l'initialisation de la compatibilité tierce, il est généralement préférable de créer des identifiants d'application Web. Pour savoir comment créer des identifiants d'application Web, consultez Créer des identifiants.
À la fin de cette étape, vous disposerez d'un fichier contenant un ID client et un code secret client.
Cliquez sur le bouton des paramètres, puis cochez la case Use your own auth credentials (Utiliser vos propres identifiants d'autorisation).
Saisissez l'ID client et le code secret client de l'étape 1.
Cliquez sur Fermer.
Dans le champ "Champs d'application", saisissez https://www.googleapis.com/auth/cloud_search.settings, puis cliquez sur le bouton Authorize (Autoriser). OAuth 2 Playground renvoie un code d'autorisation.
Cliquez sur Exchange authorization code for tokens (Échanger le code d'autorisation contre des jetons). Un jeton est renvoyé.
Pour initialiser la compatibilité tierce avec Cloud Search, utilisez la commande curl suivante. Veillez à remplacer [YOUR_ACCESS_TOKEN] par le jeton obtenu à l'étape 2.
Voici quelques étapes supplémentaires que vous pouvez effectuer :
Si vous envisagez d'utiliser Google Cloud Search avec un dépôt de données non-Google, tel que Microsoft® SharePoint®, vous devez créer une source de données. Pour ce faire, suivez les instructions de la page Ajouter une source de données pour les recherches.
Une fois que vous avez configuré votre source de données, vous pouvez créer et enregistrer un schéma afin d'indiquer comment Google Cloud Search doit représenter les données du dépôt.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/29 (UTC).
[null,null,["Dernière mise à jour le 2025/08/29 (UTC)."],[],[],null,["# Configure access to the Google Cloud Search API\n\nYou 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------------------------\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-----------------\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-------------------------------------\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-------------------------\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---------------------------------\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----------\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."]]