Import from AlloyDB for PostgreSQL (Public Preview)
Stay organized with collections
Save and categorize content based on your preferences.
To ingest data from AlloyDB for PostgreSQL, use the following steps to create
a data store and ingest data using either the Google Cloud console or the API.
Set up AlloyDB for PostgreSQL access from a different project
To give Agentspace access to AlloyDB for PostgreSQL data that's
in a different project, follow these steps:
Replace the following PROJECT_NUMBER variable with your
Agentspace project number, and then copy the contents of this
code block. This is your Agentspace service account
identifier:
Specify the project ID, location ID, cluster ID, database ID, and table ID
of the data that you plan to import.
Click Continue.
Choose a region for your data store.
Enter a name for your data store.
Click Create.
To check the status of your ingestion, go to the Data Stores page
and click your data store name to see details about it on its Data page.
When the status column on the Activity tab changes from In progress
to Import completed, the ingestion is complete.
Depending on the size of your data, ingestion can take several
minutes or several hours.
REST
To use the command line to create a data store and ingest data from
AlloyDB for PostgreSQL, follow these steps:
DATA_STORE_ID: the ID of the data store. The ID can
contain only lowercase letters, digits, underscores, and hyphens.
ALLOYDB_PROJECT_ID: the ID of your
AlloyDB for PostgreSQL project.
LOCATION_ID: the ID of your AlloyDB for PostgreSQL
location.
CLUSTER_ID: the ID of your AlloyDB for PostgreSQL
cluster.
DATABASE_ID: the ID of your AlloyDB for PostgreSQL
database.
TABLE_ID: the ID of your AlloyDB for PostgreSQL
table.
RECONCILIATION_MODE: optional. Values are FULL and
INCREMENTAL. Default is INCREMENTAL. Specifying INCREMENTAL
causes an incremental refresh of data from AlloyDB for PostgreSQL to your
data store. This does an upsert operation, which adds new documents and
replaces existing documents with updated documents with the same ID.
Specifying FULL causes a full rebase of the documents in your data store. In other words, new and updated documents are added to your data store, and documents that are not in AlloyDB for PostgreSQL are removed
from your data store. The FULL mode is helpful if you want to
automatically delete documents that you no longer need.
AUTO_GENERATE_IDS: optional. Specifies whether to
automatically generate document IDs. If set to true, document IDs
are generated based on a hash of the payload. Note that generated
document IDs might not remain consistent over multiple imports. If
you auto-generate IDs over multiple imports, Google highly
recommends setting reconciliationMode to FULL to maintain
consistent document IDs.
ID_FIELD: optional. Specifies which fields are the
document IDs.
Next steps
To attach your data store to an app, create an app and select your data store
following the steps in
Create a search app.
To preview how your search results appear after your app and data store are
set up, see
Preview search results.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[],[],null,["# Import from AlloyDB for PostgreSQL (Public Preview)\n\n| **Note:** Importing data from AlloyDB for PostgreSQL is in Public preview.\n\nTo ingest data from AlloyDB for PostgreSQL, use the following steps to create\na data store and ingest data using either the Google Cloud console or the API.\n\nIf your AlloyDB for PostgreSQL data is in the same project as\nAgentspace project, go to [Import data from\nAlloyDB for PostgreSQL](#alloydb-procedure).\n\nIf your AlloyDB for PostgreSQL data is in a different project than your\nAgentspace project, go to [Set up AlloyDB for PostgreSQL\naccess](#set-up-alloydb-access).\n\nSet up AlloyDB for PostgreSQL access from a different project\n-------------------------------------------------------------\n\nTo give Agentspace access to AlloyDB for PostgreSQL data that's\nin a different project, follow these steps:\n\n1. Replace the following \u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e variable with your\n Agentspace project number, and then copy the contents of this\n code block. This is your Agentspace service account\n identifier:\n\n service-\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e@gcp-sa-discoveryengine.iam.gserviceaccount.com\n\n2. Switch to the Google Cloud project where your AlloyDB for PostgreSQL data\n resides.\n\n3. Go to the **IAM** page.\n\n [IAM](https://console.cloud.google.com/iam-admin/iam)\n4. Click **Grant Access**.\n\n5. For **New principals** , enter the Agentspace service account\n identifier and\n select the **Cloud AlloyDB \\\u003e Cloud AlloyDB Admin** role.\n\n6. Click **Save**.\n\n7. Switch back to your Agentspace project.\n\nNext, go to [Import data from AlloyDB for PostgreSQL](#alloydb-procedure).\n\nImport data from AlloyDB for PostgreSQL\n---------------------------------------\n\n### Console\n\nTo use the console to ingest data from AlloyDB for PostgreSQL, follow these\nsteps:\n\n1. In the Google Cloud console, go to the **Agentspace** page.\n\n [Agentspace](https://console.cloud.google.com/gen-app-builder/)\n2. In the navigation menu, click **Data Stores**.\n\n3. Click **Create data store**.\n\n4. On the **Source** page, select **AlloyDB**.\n\n5. Specify the project ID, location ID, cluster ID, database ID, and table ID\n of the data that you plan to import.\n\n6. Click **Continue**.\n\n7. Choose a region for your data store.\n\n8. Enter a name for your data store.\n\n9. Click **Create**.\n\n10. To check the status of your ingestion, go to the **Data Stores** page\n and click your data store name to see details about it on its **Data** page.\n When the status column on the **Activity** tab changes from **In progress**\n to **Import completed**, the ingestion is complete.\n\n Depending on the size of your data, ingestion can take several\n minutes or several hours.\n\n### REST\n\nTo use the command line to create a data store and ingest data from\nAlloyDB for PostgreSQL, follow these steps:\n\n1. Create a data store.\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/dataStores?dataStoreId=\u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e\" \\\n -d '{\n \"displayName\": \"\u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e\",\n \"industryVertical\": \"GENERIC\",\n \"solutionTypes\": [\"SOLUTION_TYPE_SEARCH\"],\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your project.\n - \u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.\n - \u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e: the display name of the data store. This might be displayed in the Google Cloud console.\n2. Import data from AlloyDB for PostgreSQL.\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://discoveryengine.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/dataStores/\u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e/branches/0/documents:import\" \\\n -d '{\n \"alloyDbSource\": {\n \"projectId\": \"\u003cvar translate=\"no\"\u003eALLOYDB_PROJECT_ID\u003c/var\u003e\",\n \"locationId\": \"\u003cvar translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e\",\n \"clusterId\": \"\u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e\",\n \"databaseId\": \"\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e\",\n \"tableId\": \"\u003cvar translate=\"no\"\u003eTABLE_ID\u003c/var\u003e\",\n },\n \"reconciliationMode\": \"\u003cvar translate=\"no\"\u003eRECONCILIATION_MODE\u003c/var\u003e\",\n \"autoGenerateIds\": \"\u003cvar translate=\"no\"\u003eAUTO_GENERATE_IDS\u003c/var\u003e\",\n \"idField\": \"\u003cvar translate=\"no\"\u003eID_FIELD\u003c/var\u003e\",\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Agentspace project.\n - \u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.\n - \u003cvar translate=\"no\"\u003eALLOYDB_PROJECT_ID\u003c/var\u003e: the ID of your AlloyDB for PostgreSQL project.\n - \u003cvar translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e: the ID of your AlloyDB for PostgreSQL location.\n - \u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e: the ID of your AlloyDB for PostgreSQL cluster.\n - \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e: the ID of your AlloyDB for PostgreSQL database.\n - \u003cvar translate=\"no\"\u003eTABLE_ID\u003c/var\u003e: the ID of your AlloyDB for PostgreSQL table.\n - \u003cvar translate=\"no\"\u003eRECONCILIATION_MODE\u003c/var\u003e: optional. Values are `FULL` and `INCREMENTAL`. Default is `INCREMENTAL`. Specifying `INCREMENTAL` causes an incremental refresh of data from AlloyDB for PostgreSQL to your data store. This does an upsert operation, which adds new documents and replaces existing documents with updated documents with the same ID. Specifying `FULL` causes a full rebase of the documents in your data store. In other words, new and updated documents are added to your data store, and documents that are not in AlloyDB for PostgreSQL are removed from your data store. The `FULL` mode is helpful if you want to automatically delete documents that you no longer need.\n - \u003cvar translate=\"no\"\u003eAUTO_GENERATE_IDS\u003c/var\u003e: optional. Specifies whether to automatically generate document IDs. If set to `true`, document IDs are generated based on a hash of the payload. Note that generated document IDs might not remain consistent over multiple imports. If you auto-generate IDs over multiple imports, Google highly recommends setting `reconciliationMode` to `FULL` to maintain consistent document IDs.\n - \u003cvar translate=\"no\"\u003eID_FIELD\u003c/var\u003e: optional. Specifies which fields are the document IDs.\n\n\u003cbr /\u003e\n\nNext steps\n----------\n\n- To attach your data store to an app, create an app and select your data store\n following the steps in\n [Create a search app](/agentspace/docs/create-app).\n\n- To preview how your search results appear after your app and data store are\n set up, see\n [Preview search results](/agentspace/docs/preview-search-results)."]]