To ingest data from Firestore, use the following steps to create a data store and ingest data using either the Google Cloud console or the API.
If your Firestore data is in the same project as Agentspace Enterprise, go to Import data from Firestore.
If your Firestore data is in a different project than your Agentspace Enterprise project, go to Set up Firestore access.
Set up Firestore access from a different project
To give Agentspace Enterprise access to Firestore data that's in a different project, follow these steps:
Replace the following
PROJECT_NUMBER
variable with your Agentspace Enterprise project number, and then copy the contents of this code block. This is your Agentspace Enterprise service account identifier:service-PROJECT_NUMBER@gcp-sa-discoveryengine.iam.gserviceaccount.com
Go to the IAM & Admin page.
Switch to your Firestore project on the IAM & Admin page and click Grant Access.
For New principals, enter the instance's service account identifier and select the Datastore > Cloud Datastore Import Export Admin role.
Click Save.
Switch back to your Agentspace Enterprise project.
Next, go to Import data from Firestore.
Import data from Firestore
Console
To use the console to ingest data from Firestore, follow these steps:
In the Google Cloud console, go to the Agentspace page.
Go to the Data Stores page.
Click New data store.
On the Source page, select Firestore.
Specify the project ID, database ID, and collection 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 Firestore, follow these steps:
Create a data store.
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: PROJECT_ID" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores?dataStoreId=DATA_STORE_ID" \ -d '{ "displayName": "DISPLAY_NAME", "industryVertical": "GENERIC", "solutionTypes": ["SOLUTION_TYPE_SEARCH"], }'
Replace the following:
PROJECT_ID
: the ID of your project.DATA_STORE_ID
: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.DISPLAY_NAME
: the display name of the data store. This might be displayed in the Google Cloud console.
Import data from Firestore.
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents:import" \ -d '{ "firestoreSource": { "projectId": "FIRESTORE_PROJECT_ID", "databaseId": "DATABASE_ID", "collectionId": "COLLECTION_ID", }, "reconciliationMode": "RECONCILIATION_MODE", "autoGenerateIds": "AUTO_GENERATE_IDS", "idField": "ID_FIELD", }'
Replace the following:
PROJECT_ID
: the ID of your Agentspace Enterprise project.DATA_STORE_ID
: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.FIRESTORE_PROJECT_ID
: the ID of your Firestore project.DATABASE_ID
: the ID of your Firestore database.COLLECTION_ID
: the ID of your Firestore collection.RECONCILIATION_MODE
: optional. Values areFULL
andINCREMENTAL
. Default isINCREMENTAL
. SpecifyingINCREMENTAL
causes an incremental refresh of data from Firestore to your data store. This does an upsert operation, which adds new documents and replaces existing documents with updated documents with the same ID. SpecifyingFULL
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 Firestore are removed from your data store. TheFULL
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 totrue
, 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 settingreconciliationMode
toFULL
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.