Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Avec Vertex AI Search, vous pouvez rechercher des images à l'aide d'une application avec des données de site Web. Vous fournissez une requête sous la forme d'une chaîne de texte ou d'une image, et la méthode default_config.search renvoie des images pour cette requête.
Avant de commencer
Assurez-vous de remplir les conditions préalables suivantes. Les exigences varient selon que vous effectuez une recherche à l'aide d'une requête textuelle ou d'une requête d'image.
Si vous effectuez une recherche à l'aide d'une requête textuelle dans votre application de recherche de sites Web, assurez-vous que les fonctionnalités de l'édition Enterprise sont activées.
Si vous effectuez une recherche à l'aide d'une requête d'image dans votre application de recherche de sites Web, assurez-vous que les éléments suivants sont activés :
Sur la page Applications, recherchez le nom de votre application et récupérez son ID dans la colonne ID.
Appelez la méthode engines.servingConfigs.search en spécifiant 1 pour search_type. Choisissez la syntaxe de la méthode selon que votre requête est du texte ou des octets d'image.
QUERY : texte de la requête de recherche. Par exemple, "Voitures avec phares ronds" ou "montre-moi une robe à rayures".
IMAGE_BYTES : image en octets encodés en base64. Les formats acceptés sont JPEG, PNG et BMP.
PAGE_SIZE (facultatif) : Nombre de résultats renvoyés par la recherche. La valeur par défaut est de 10 pour la recherche sur le site Web.
Les valeurs inférieures à 0 génèrent une erreur.
Les valeurs supérieures à 100 sont définies sur 100.
OFFSET (facultatif) : Index de départ des résultats.
La valeur par défaut est 0.
Par exemple, si le décalage est de 2 et la taille de la page de 10, les résultats 2 à 11 sont renvoyés.
Vérifiez la réponse. Consultez le tableau suivant pour obtenir la description des champs :
Champ
Description
title
Titre en texte brut de la page Web contenant l'image
htmlTitle
Titre, en HTML, de la page Web contenant l'image
displayLink
Version abrégée de l'URL du résultat de recherche, généralement le nom de domaine (par exemple, www.example.com)
link
URL de l'image
image.contextLink
Lien de contexte : URL pointant vers la page Web contenant l'image
image.byteSize
Taille de l'image, en octets
image.width
Largeur de l'image, en pixels
image.height
Hauteur de l'image, en pixels
image.thumbnailWidth
Largeur de la miniature, en pixels
image.thumbnailHeight
Hauteur de la miniature, en pixels
image.thumbnailLink
URL de la vignette
mime
Type MIME de l'image
fileFormat
Format de fichier de l'image
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/09/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/05 (UTC)."],[[["\u003cp\u003eVertex AI Search enables searching for images within website data using either a text string or an image as the query input.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize image search, Enterprise edition features and advanced website indexing must be enabled within your app's settings.\u003c/p\u003e\n"],["\u003cp\u003eImage search functionality is initiated using the \u003ccode\u003eengines.servingConfigs.search\u003c/code\u003e method via command line, which is preferred over the datastore search method, and specifying \u003ccode\u003e1\u003c/code\u003e for the \u003ccode\u003esearch_type\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the command line, you will need to use your project ID and app ID, as well as a text query or base64-encoded image bytes.\u003c/p\u003e\n"],["\u003cp\u003eThe search results provide detailed information about the matching images, including the title of the webpage containing the image, the image URL, the context link, size, and dimensions.\u003c/p\u003e\n"]]],[],null,["# Search for images on websites\n\nWith Vertex AI Search, you can search for images using a app with\nwebsite data. You supply a query in the form of a text string or an image, and\nthe `default_config.search` method returns images for that query.\n| **Note:** Image search is not available using the Google Cloud console.\n\nBefore you begin\n----------------\n\nMake sure you satisfy the following prerequisites. Requirements vary depending\non whether you search using a text query or an image query.\n\n- If you search using a text query in your website search app, make sure the\n following is turned on: [Enterprise edition features](/generative-ai-app-builder/docs/about-advanced-features#enterprise-features)\n\n- If you search using an image query in your website search app, make sure the\n following are turned on:\n\n - [Enterprise edition features](/generative-ai-app-builder/docs/about-advanced-features#enterprise-features)\n\n - [Advanced website indexing](/generative-ai-app-builder/docs/about-advanced-features#advanced-website-indexing)\n\nPreview image search\n--------------------\n\nTo use the command line to preview image results for a website,\nuse the [`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method:\n| **Note:** You can search over an app using the [`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method and you can search over a data store using the [`dataStores.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/search) method. For the following procedure, Google recommends searching using the `engines.servingConfigs.search` method.\n\n1. Find your app ID. If you already have your app ID, skip to the next step.\n\n 1. In the Google Cloud console, go to the **AI Applications** page.\n\n [Go to Apps](https://console.cloud.google.com/gen-app-builder/engines)\n 2. On the **Apps** page, find the name of your app and get the app's ID from\n the **ID** column.\n\n2. Call the\n [`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search)\n method, specifying `1` for the `search_type`. Choose the method syntax\n depending on whether your query is\n text or image bytes.\n\n **Key Term:** In Vertex AI Search, the term *app* can be used interchangeably with the term *engine* in the context of APIs. \n\n ### Query is a text string\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n -H \"X-Goog-User-Project: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\" \\\n \"https://discoveryengine.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_config:search\" \\\n -d '{\n \"servingConfig\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search\",\n \"query\": \"\u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e\",\n \"pageSize\": \"\u003cvar translate=\"no\"\u003ePAGE_SIZE\u003c/var\u003e\",\n \"offset\": \"\u003cvar translate=\"no\"\u003eOFFSET\u003c/var\u003e\",\n \"params\": {\"search_type\": 1}\n }'\n\n ### Query is an image\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n -H \"X-Goog-User-Project: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\" \\\n \"https://discoveryengine.googleapis.com/v1beta/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search:search\" \\\n -d '{\n \"servingConfig\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search\",\n \"imageQuery\": {\"imageBytes\":\"\u003cvar translate=\"no\"\u003eIMAGE_BYTES\u003c/var\u003e\"},\n \"pageSize\": \"\u003cvar translate=\"no\"\u003ePAGE_SIZE\u003c/var\u003e\",\n \"offset\": \"\u003cvar translate=\"no\"\u003eOFFSET\u003c/var\u003e\",\n \"params\": {\"search_type\": 1}\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your project.\n\n - \u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e: the ID of your app.\n\n - \u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e: the search query text. For example, \"Round headlight\n cars\" or \"show me dress with stripes.\"\n\n - \u003cvar translate=\"no\"\u003eIMAGE_BYTES\u003c/var\u003e: the image in Base64 encoded bytes. Supported\n formats are JPEG, PNG, and BMP.\n\n - \u003cvar translate=\"no\"\u003ePAGE_SIZE\u003c/var\u003e: optional. The number of results returned by the\n search. The default value is 10 for website search.\n\n - Values below 0 cause an error.\n - Values above 100 cause the value to be set to 100.\n - \u003cvar translate=\"no\"\u003eOFFSET\u003c/var\u003e: optional. The starting index of the results.\n The default value is 0.\n\n For example, if the offset is 2 and the page size is 10, results 2\n through 11 are returned.\n3. Review the response. See the following table for field descriptions:"]]