You can create data stores from BigQuery tables in two ways:
One-time ingestion: You import data from a BigQuery table into a
data store. The data in the data store does not change unless you manuallyrefresh the data.
Periodic ingestion: You import data from one or more BigQuery
tables, and you set a sync frequency that determines how often the data
stores are updated with the most recent data from the BigQuery
dataset.
The following table compares the two ways that you can import BigQuery
data into Vertex AI Search data stores.
One-time ingestion
Periodic ingestion
Generally available (GA).
Public preview.
Data must be refreshed manually.
Data updates automatically every 1, 3, or 5 days. Data cannot be
manually refreshed.
Vertex AI Search creates a single data store from onetablein a BigQuery.
Vertex AI Search creates adata connectorfor
a BigQuerydatasetand a data store (called anentitydata store) for each table specified. For each data
connector, the tables must have the same data type (for example,
structured) and be in the same BigQuery dataset.
Data from multiple tables can be combined in one data store by first
ingesting data from one table and then more data from another source or
BigQuery table.
Because manual data import is not supported, the data in an entity
data store can only be sourced from one BigQuery table.
Data source access control is supported.
Data source access control is not supported. The imported data can
contain access controls but these controls won't be respected.
You can create a data store using either the
Google Cloud console or the API.
You must use the console to create data connectors and their entity
data stores.
CMEK-compliant.
CMEK-compliant.
Import once from BigQuery
To ingest data from a BigQuery table, use the following steps to create
a data store and ingest data using either the Google Cloud console or the API.
In theBigQuery pathfield, clickBrowse, select a table that you
haveprepared for ingesting, and then clickSelect.
Alternatively, enter the table location directly in theBigQuery pathfield.
ClickContinue.
If you are doing one-time import of structured data:
Map fields to key properties.
If there are important fields missing from the schema, useAdd new
fieldto add them.
To check the status of your ingestion, go to theData Storespage
and click your data store name to see details about it on itsDatapage.
When the status column on theActivitytab changes fromIn progresstoImport completed, the ingestion is complete.
Depending on the size of your data, ingestion can take several
minutes to several hours.
REST
To use the command line to create a data store and import data from
BigQuery, follow these steps.
DATA_STORE_ID: the ID of the Vertex AI Search data store that you want to create. This ID can contain only lowercase
letters, digits, underscores, and hyphens.
DATA_STORE_DISPLAY_NAME: the display name of the Vertex AI
Search data store that you want to create.
Import data from BigQuery.
If you defined a schema, make sure the data conforms to that schema.
DATA_STORE_ID: the ID of the Vertex AI Search data store.
DATASET_ID: the ID of the BigQuery
dataset.
TABLE_ID: the ID of the BigQuery table.
If the BigQuery table is not underPROJECT_ID, you need to give the service accountservice-<project
number>@gcp-sa-discoveryengine.iam.gserviceaccount.com"BigQuery Data Viewer" permission for the
BigQuery table. For example, if you are importing
a BigQuery table from source project "123" to
destination project "456", giveservice-456@gcp-sa-discoveryengine.iam.gserviceaccount.compermissions for the BigQuery table under
project "123".
DATA_SCHEMA: optional. Values aredocumentandcustom. The default isdocument.
document: the BigQuery table
that you use must conform to the default BigQuery
schema provided inPrepare data for ingesting.
You can define the ID of each document yourself,
while wrapping all the data in the jsonData string.
custom: Any BigQuery table
schema is accepted, and Vertex AI Search automatically
generates the IDs for each document that is imported.
ERROR_DIRECTORY: optional. A Cloud Storage directory
for error information about the import—for example,gs://<your-gcs-bucket>/directory/import_errors. Google recommends
leaving this field empty to let Vertex AI Search
automatically create a temporary directory.
RECONCILIATION_MODE: optional. Values areFULLandINCREMENTAL. Default isINCREMENTAL. SpecifyingINCREMENTALcauses an incremental refresh of data from BigQuery
to your data store. This does an upsert operation, which adds new
documents and replaces existing documents with updated documents
with the same ID. SpecifyingFULLcauses 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 BigQuery are removed from your data store. TheFULLmode 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 settingreconciliationModetoFULLto maintain
consistent document IDs.
SpecifyautoGenerateIdsonly whenbigquerySource.dataSchemais
set tocustom. Otherwise anINVALID_ARGUMENTerror is
returned. If you don't specifyautoGenerateIdsor set it tofalse, you must specifyidField. Otherwise the documents fail to
import.
ID_FIELD: optional. Specifies which fields are the
document IDs. For BigQuery source files,idFieldindicates the name of the column in the BigQuery
table that contains the document IDs.
SpecifyidFieldonly when: (1)bigquerySource.dataSchemais set
tocustom, and (2)auto_generate_idsis set tofalseor is
unspecified. Otherwise anINVALID_ARGUMENTerror is returned.
The value of the BigQuery column name must be of
string type, must be between 1 and 63 characters, and must conform
toRFC-1034. Otherwise, the
documents fail to import.
usingGoogle.Cloud.DiscoveryEngine.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedDataStoreServiceClientSnippets{/// <summary>Snippet for CreateDataStore</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidCreateDataStoreRequestObject(){// Create clientDataStoreServiceClientdataStoreServiceClient=DataStoreServiceClient.Create();// Initialize request argument(s)CreateDataStoreRequestrequest=newCreateDataStoreRequest{ParentAsCollectionName=CollectionName.FromProjectLocationCollection("[PROJECT]","[LOCATION]","[COLLECTION]"),DataStore=newDataStore(),DataStoreId="",CreateAdvancedSiteSearch=false,CmekConfigNameAsCmekConfigName=CmekConfigName.FromProjectLocation("[PROJECT]","[LOCATION]"),SkipDefaultSchemaCreation=false,};// Make the requestOperation<DataStore,CreateDataStoreMetadata>response=dataStoreServiceClient.CreateDataStore(request);// Poll until the returned long-running operation is completeOperation<DataStore,CreateDataStoreMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultDataStoreresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<DataStore,CreateDataStoreMetadata>retrievedResponse=dataStoreServiceClient.PollOnceCreateDataStore(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultDataStoreretrievedResult=retrievedResponse.Result;}}}
Import documents
usingGoogle.Cloud.DiscoveryEngine.V1;usingGoogle.LongRunning;usingGoogle.Protobuf.WellKnownTypes;publicsealedpartialclassGeneratedDocumentServiceClientSnippets{/// <summary>Snippet for ImportDocuments</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidImportDocumentsRequestObject(){// Create clientDocumentServiceClientdocumentServiceClient=DocumentServiceClient.Create();// Initialize request argument(s)ImportDocumentsRequestrequest=newImportDocumentsRequest{ParentAsBranchName=BranchName.FromProjectLocationDataStoreBranch("[PROJECT]","[LOCATION]","[DATA_STORE]","[BRANCH]"),InlineSource=newImportDocumentsRequest.Types.InlineSource(),ErrorConfig=newImportErrorConfig(),ReconciliationMode=ImportDocumentsRequest.Types.ReconciliationMode.Unspecified,UpdateMask=newFieldMask(),AutoGenerateIds=false,IdField="",ForceRefreshContent=false,};// Make the requestOperation<ImportDocumentsResponse,ImportDocumentsMetadata>response=documentServiceClient.ImportDocuments(request);// Poll until the returned long-running operation is completeOperation<ImportDocumentsResponse,ImportDocumentsMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultImportDocumentsResponseresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<ImportDocumentsResponse,ImportDocumentsMetadata>retrievedResponse=documentServiceClient.PollOnceImportDocuments(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultImportDocumentsResponseretrievedResult=retrievedResponse.Result;}}}
packagemainimport("context"discoveryengine"cloud.google.com/go/discoveryengine/apiv1"discoveryenginepb"cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=discoveryengine.NewDataStoreClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&discoveryenginepb.CreateDataStoreRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#CreateDataStoreRequest.}op,err:=c.CreateDataStore(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}
Import documents
packagemainimport("context"discoveryengine"cloud.google.com/go/discoveryengine/apiv1"discoveryenginepb"cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=discoveryengine.NewDocumentClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&discoveryenginepb.ImportDocumentsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#ImportDocumentsRequest.}op,err:=c.ImportDocuments(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}
importcom.google.cloud.discoveryengine.v1.CollectionName;importcom.google.cloud.discoveryengine.v1.CreateDataStoreRequest;importcom.google.cloud.discoveryengine.v1.DataStore;importcom.google.cloud.discoveryengine.v1.DataStoreServiceClient;publicclassSyncCreateDataStore{publicstaticvoidmain(String[]args)throwsException{syncCreateDataStore();}publicstaticvoidsyncCreateDataStore()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DataStoreServiceClientdataStoreServiceClient=DataStoreServiceClient.create()){CreateDataStoreRequestrequest=CreateDataStoreRequest.newBuilder().setParent(CollectionName.of("[PROJECT]","[LOCATION]","[COLLECTION]").toString()).setDataStore(DataStore.newBuilder().build()).setDataStoreId("dataStoreId929489618").setCreateAdvancedSiteSearch(true).setSkipDefaultSchemaCreation(true).build();DataStoreresponse=dataStoreServiceClient.createDataStoreAsync(request).get();}}}
Import documents
importcom.google.cloud.discoveryengine.v1.BranchName;importcom.google.cloud.discoveryengine.v1.DocumentServiceClient;importcom.google.cloud.discoveryengine.v1.ImportDocumentsRequest;importcom.google.cloud.discoveryengine.v1.ImportDocumentsResponse;importcom.google.cloud.discoveryengine.v1.ImportErrorConfig;importcom.google.protobuf.FieldMask;publicclassSyncImportDocuments{publicstaticvoidmain(String[]args)throwsException{syncImportDocuments();}publicstaticvoidsyncImportDocuments()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentServiceClientdocumentServiceClient=DocumentServiceClient.create()){ImportDocumentsRequestrequest=ImportDocumentsRequest.newBuilder().setParent(BranchName.ofProjectLocationDataStoreBranchName("[PROJECT]","[LOCATION]","[DATA_STORE]","[BRANCH]").toString()).setErrorConfig(ImportErrorConfig.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).setAutoGenerateIds(true).setIdField("idField1629396127").setForceRefreshContent(true).build();ImportDocumentsResponseresponse=documentServiceClient.importDocumentsAsync(request).get();}}}
/*** This snippet has been automatically generated and should be regarded as a code template only.* It will require modifications to work.* It may require correct/in-range values for request initialization.* TODO(developer): Uncomment these variables before running the sample.*//*** Resource name of the CmekConfig to use for protecting this DataStore.*/// const cmekConfigName = 'abc123'/*** DataStore without CMEK protections. If a default CmekConfig is set for* the project, setting this field will override the default CmekConfig as* well.*/// const disableCmek = true/*** Required. The parent resource name, such as* `projects/{project}/locations/{location}/collections/{collection}`.*/// const parent = 'abc123'/*** Required. The DataStore google.cloud.discoveryengine.v1.DataStore to* create.*/// const dataStore = {}/*** Required. The ID to use for the* DataStore google.cloud.discoveryengine.v1.DataStore, which will become* the final component of the* DataStore google.cloud.discoveryengine.v1.DataStore's resource name.* This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034)* standard with a length limit of 63 characters. Otherwise, an* INVALID_ARGUMENT error is returned.*/// const dataStoreId = 'abc123'/*** A boolean flag indicating whether user want to directly create an advanced* data store for site search.* If the data store is not configured as site* search (GENERIC vertical and PUBLIC_WEBSITE content_config), this flag will* be ignored.*/// const createAdvancedSiteSearch = true/*** A boolean flag indicating whether to skip the default schema creation for* the data store. Only enable this flag if you are certain that the default* schema is incompatible with your use case.* If set to true, you must manually create a schema for the data store before* any documents can be ingested.* This flag cannot be specified if `data_store.starting_schema` is specified.*/// const skipDefaultSchemaCreation = true// Imports the Discoveryengine libraryconst{DataStoreServiceClient}=require('@google-cloud/discoveryengine').v1;// Instantiates a clientconstdiscoveryengineClient=newDataStoreServiceClient();asyncfunctioncallCreateDataStore(){// Construct requestconstrequest={parent,dataStore,dataStoreId,};// Run requestconst[operation]=awaitdiscoveryengineClient.createDataStore(request);const[response]=awaitoperation.promise();console.log(response);}callCreateDataStore();
Import documents
/*** This snippet has been automatically generated and should be regarded as a code template only.* It will require modifications to work.* It may require correct/in-range values for request initialization.* TODO(developer): Uncomment these variables before running the sample.*//*** The Inline source for the input content for documents.*/// const inlineSource = {}/*** Cloud Storage location for the input content.*/// const gcsSource = {}/*** BigQuery input source.*/// const bigquerySource = {}/*** FhirStore input source.*/// const fhirStoreSource = {}/*** Spanner input source.*/// const spannerSource = {}/*** Cloud SQL input source.*/// const cloudSqlSource = {}/*** Firestore input source.*/// const firestoreSource = {}/*** AlloyDB input source.*/// const alloyDbSource = {}/*** Cloud Bigtable input source.*/// const bigtableSource = {}/*** Required. The parent branch resource name, such as* `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.* Requires create/update permission.*/// const parent = 'abc123'/*** The desired location of errors incurred during the Import.*/// const errorConfig = {}/*** The mode of reconciliation between existing documents and the documents to* be imported. Defaults to* ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL.*/// const reconciliationMode = {}/*** Indicates which fields in the provided imported documents to update. If* not set, the default is to update all fields.*/// const updateMask = {}/*** Whether to automatically generate IDs for the documents if absent.* If set to `true`,* Document.id google.cloud.discoveryengine.v1.Document.id s are* automatically generated based on the hash of the payload, where IDs may not* be consistent during multiple imports. In which case* ReconciliationMode.FULL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL* is highly recommended to avoid duplicate contents. If unset or set to* `false`, Document.id google.cloud.discoveryengine.v1.Document.id s have* to be specified using* id_field google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field,* otherwise, documents without IDs fail to be imported.* Supported data sources:* * GcsSource google.cloud.discoveryengine.v1.GcsSource.* GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource.* BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * SpannerSource google.cloud.discoveryengine.v1.SpannerSource.* * CloudSqlSource google.cloud.discoveryengine.v1.CloudSqlSource.* * FirestoreSource google.cloud.discoveryengine.v1.FirestoreSource.* * BigtableSource google.cloud.discoveryengine.v1.BigtableSource.*/// const autoGenerateIds = true/*** The field indicates the ID field or column to be used as unique IDs of* the documents.* For GcsSource google.cloud.discoveryengine.v1.GcsSource it is the key of* the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`.* For others, it may be the column name of the table where the unique ids are* stored.* The values of the JSON field or the table column are used as the* Document.id google.cloud.discoveryengine.v1.Document.id s. The JSON field* or the table column must be of string type, and the values must be set as* valid strings conform to RFC-1034 (https://tools.ietf.org/html/rfc1034)* with 1-63 characters. Otherwise, documents without valid IDs fail to be* imported.* Only set this field when* auto_generate_ids google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids* is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown.* If it is unset, a default value `_id` is used when importing from the* allowed data sources.* Supported data sources:* * GcsSource google.cloud.discoveryengine.v1.GcsSource.* GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource.* BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * SpannerSource google.cloud.discoveryengine.v1.SpannerSource.* * CloudSqlSource google.cloud.discoveryengine.v1.CloudSqlSource.* * FirestoreSource google.cloud.discoveryengine.v1.FirestoreSource.* * BigtableSource google.cloud.discoveryengine.v1.BigtableSource.*/// const idField = 'abc123'/*** Optional. Whether to force refresh the unstructured content of the* documents.* If set to `true`, the content part of the documents will be refreshed* regardless of the update status of the referencing content.*/// const forceRefreshContent = true// Imports the Discoveryengine libraryconst{DocumentServiceClient}=require('@google-cloud/discoveryengine').v1;// Instantiates a clientconstdiscoveryengineClient=newDocumentServiceClient();asyncfunctioncallImportDocuments(){// Construct requestconstrequest={parent,};// Run requestconst[operation]=awaitdiscoveryengineClient.importDocuments(request);const[response]=awaitoperation.promise();console.log(response);}callImportDocuments();
fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdiscoveryengine# TODO(developer): Uncomment these variables before running the sample.# project_id = "YOUR_PROJECT_ID"# location = "YOUR_LOCATION" # Values: "global"# data_store_id = "YOUR_DATA_STORE_ID"defcreate_data_store_sample(project_id:str,location:str,data_store_id:str,)->str:# For more information, refer to:# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_storeclient_options=(ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")iflocation!="global"elseNone)# Create a clientclient=discoveryengine.DataStoreServiceClient(client_options=client_options)# The full resource name of the collection# e.g. projects/{project}/locations/{location}/collections/default_collectionparent=client.collection_path(project=project_id,location=location,collection="default_collection",)data_store=discoveryengine.DataStore(display_name="My Data Store",# Options: GENERIC, MEDIA, HEALTHCARE_FHIRindustry_vertical=discoveryengine.IndustryVertical.GENERIC,# Options: SOLUTION_TYPE_RECOMMENDATION, SOLUTION_TYPE_SEARCH, SOLUTION_TYPE_CHAT, SOLUTION_TYPE_GENERATIVE_CHATsolution_types=[discoveryengine.SolutionType.SOLUTION_TYPE_SEARCH],# TODO(developer): Update content_config based on data store type.# Options: NO_CONTENT, CONTENT_REQUIRED, PUBLIC_WEBSITEcontent_config=discoveryengine.DataStore.ContentConfig.CONTENT_REQUIRED,)request=discoveryengine.CreateDataStoreRequest(parent=parent,data_store_id=data_store_id,data_store=data_store,# Optional: For Advanced Site Search Only# create_advanced_site_search=True,)# Make the requestoperation=client.create_data_store(request=request)print(f"Waiting for operation to complete:{operation.operation.name}")response=operation.result()# After the operation is complete,# get information from operation metadatametadata=discoveryengine.CreateDataStoreMetadata(operation.metadata)# Handle the responseprint(response)print(metadata)returnoperation.operation.name
Import documents
fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdiscoveryengine# TODO(developer): Uncomment these variables before running the sample.# project_id = "YOUR_PROJECT_ID"# location = "YOUR_LOCATION" # Values: "global"# data_store_id = "YOUR_DATA_STORE_ID"# bigquery_dataset = "YOUR_BIGQUERY_DATASET"# bigquery_table = "YOUR_BIGQUERY_TABLE"# For more information, refer to:# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_storeclient_options=(ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")iflocation!="global"elseNone)# Create a clientclient=discoveryengine.DocumentServiceClient(client_options=client_options)# The full resource name of the search engine branch.# e.g. projects/{project}/locations/{location}/dataStores/{data_store_id}/branches/{branch}parent=client.branch_path(project=project_id,location=location,data_store=data_store_id,branch="default_branch",)request=discoveryengine.ImportDocumentsRequest(parent=parent,bigquery_source=discoveryengine.BigQuerySource(project_id=project_id,dataset_id=bigquery_dataset,table_id=bigquery_table,data_schema="custom",),# Options: `FULL`, `INCREMENTAL`reconciliation_mode=discoveryengine.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL,)# Make the requestoperation=client.import_documents(request=request)print(f"Waiting for operation to complete:{operation.operation.name}")response=operation.result()# After the operation is complete,# get information from operation metadatametadata=discoveryengine.ImportDocumentsMetadata(operation.metadata)# Handle the responseprint(response)print(metadata)
require"google/cloud/discovery_engine/v1"### Snippet for the create_data_store call in the DataStoreService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DiscoveryEngine::V1::DataStoreService::Client#create_data_store.#defcreate_data_store# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DiscoveryEngine::V1::DataStoreService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DiscoveryEngine::V1::CreateDataStoreRequest.new# Call the create_data_store method.result=client.create_data_storerequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend
Import documents
require"google/cloud/discovery_engine/v1"### Snippet for the import_documents call in the DocumentService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#import_documents.#defimport_documents# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest.new# Call the import_documents method.result=client.import_documentsrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend
The following procedure describes how to create a data connector that associates
a BigQuery dataset with a Vertex AI Search data
connector and how to specify a table on the dataset for each data store you want
to create. Data stores that are children of data connectors are calledentitydata stores.
Data from the dataset is synced periodically to the entity data stores. You can
specify synchronization daily, every three days, or every five days.
Console
To use the Google Cloud console to create a connector that periodically syncs data
from a BigQuery dataset to Vertex AI Search, follow these
steps:
In the Google Cloud console, go to theAI Applicationspage.
Select theSync frequency, how often you want the
Vertex AI Search connector to sync with the BigQuery
dataset. You can change the frequency later.
In theBigQuery dataset pathfield, clickBrowse, select the dataset
that contains the tables that you haveprepared for
ingesting. Alternatively, enter the table location directly
in theBigQuery pathfield. The format for the path isprojectname.datasetname.
In theTables to syncfield, clickBrowse, and then select a table
that contains the data that you want for your data store.
If there are additional tables in the dataset that that you want to use for
data stores, clickAdd tableand specify those tables too.
ClickContinue.
Choose a region for your data store, enter a name for your data connector,
and clickCreate.
You have now created a data connector, which will periodically sync data
with the BigQuery dataset. And, you have created one or more entity
data stores. The data stores have the same names as the BigQuery
tables.
To check the status of your ingestion, go to theData Storespage
and click your data connector name to see details about it on itsDatapage >Data ingestion activitytab. When the status column on theActivitytab changes fromIn progresstosucceeded, the first
ingestion is complete.
Depending on the size of your data, ingestion can take several
minutes to several hours.
After you set up your data source and import data the first time, the data store
syncs data from that source at a frequency that you select during setup.
About an hour after the data connector is created, the first sync occurs.
The next sync then occurs around 24 hours, 72 hours,
or 120 hours later.
To preview or get recommendations after your app and data store are set up,
seeGet recommendations.
Cloud Storage
You can create data stores from Cloud Storage tables in two ways:
One-time ingestion: You import data from a Cloud Storage folder or file
into a data store. The data in the data store doesn't change unless you
manuallyrefresh the data.
Periodic ingestion: You import data from a Cloud Storage folder or
file, and you set a sync frequency that determines how often the data
store is updated with the most recent data from that Cloud Storage
location.
The following table compares the two ways that you can import Cloud Storage
data into Vertex AI Search data stores.
One-time ingestion
Periodic ingestion
Generally available (GA).
Public preview.
Data must be refreshed manually.
Data updates automatically every one, three, or five days. Data cannot be
manually refreshed.
Vertex AI Search creates a single data store from one
folder or file in Cloud Storage.
Vertex AI Search creates adata connector, and
associates a data store (called anentitydata store) with it for
the file or folder that is specified. Each Cloud Storage data connector
can have a single entity data store.
Data from multiple files, folders, and buckets can be combined in one
data store by first ingesting data from one Cloud Storage location and
then more data from another location.
Because manual data import is not supported, the data in an entity
data store can only be sourced from one Cloud Storage file or folder.
Optional: If you selected unstructured documents, you can select parsing and
chunking options for your documents. To compare parsers, seeParse
documents. For information about chunking seeChunk documents for
RAG.
To select a parser, expandDocument processing optionsand specify the
parser options that you want to use.
ClickCreate.
To check the status of your ingestion, go to theData Storespage
and click your data store name to see details about it on itsDatapage.
When the status column on theActivitytab changes fromIn progresstoImport 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
Cloud Storage, follow these steps.
DATA_STORE_ID: the ID of the Vertex AI Search data store that you want to create. This ID can contain only lowercase
letters, digits, underscores, and hyphens.
DATA_STORE_DISPLAY_NAME: the display name of the Vertex AI
Search data store that you want to create.
DATA_STORE_ID: the ID of the Vertex AI Search data store.
INPUT_FILE_PATTERN: a file pattern in Cloud Storage
containing your documents.
For structured data or for unstructured data with metadata,
an example of the input file pattern isgs://<your-gcs-bucket>/directory/object.jsonand an example of
pattern matching one or more files isgs://<your-gcs-bucket>/directory/*.json.
For unstructured documents, an example isgs://<your-gcs-bucket>/directory/*.pdf. Each file that is matched
by the pattern becomes a document.
If<your-gcs-bucket>is not underPROJECT_ID, you
need to give the service accountservice-<project
number>@gcp-sa-discoveryengine.iam.gserviceaccount.com"Storage
Object Viewer" permissions for the Cloud Storage bucket. For
example, if you are importing a Cloud Storage bucket from
source project "123" to destination project "456", giveservice-456@gcp-sa-discoveryengine.iam.gserviceaccount.compermissions on the Cloud Storage bucket under project "123".
DATA_SCHEMA: optional. Values aredocument,custom,csv, andcontent. The default isdocument.
document: Upload unstructured data with metadata for
unstructured documents. Each line of the file has to follow one
of the following formats. You can define the ID of each document:
custom: Upload JSON for structured documents. The data is
organized according to a schema. You can specify the schema;
otherwise it is auto-detected. You can put the JSON string of the
document in a consistent format directly in each line, and
Vertex AI Search automatically generates the IDs
for each document imported.
content: Upload unstructured documents (PDF, HTML, DOC, TXT,
PPTX). The ID of each document is automatically generated as the
first 128 bits of SHA256(GCS_URI) encoded as a hex string. You can
specify multiple input file patterns as long as the matched files
don't exceed the 100K files limit.
csv: Include a header row in your CSV file,
with each header mapped to a document field. Specify the path to
the CSV file using theinputUrisfield.
ERROR_DIRECTORY: optional. A Cloud Storage directory
for error information about the import—for example,gs://<your-gcs-bucket>/directory/import_errors. Google recommends
leaving this field empty to let Vertex AI Search
automatically create a temporary directory.
RECONCILIATION_MODE: optional. Values areFULLandINCREMENTAL. Default isINCREMENTAL. SpecifyingINCREMENTALcauses an incremental refresh of data from Cloud Storage to your
data store. This does an upsert operation, which adds new documents
and replaces existing documents with updated documents with the same
ID. SpecifyingFULLcauses 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 Cloud Storage are
removed from your data store. TheFULLmode 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 settingreconciliationModetoFULLto maintain
consistent document IDs.
SpecifyautoGenerateIdsonly whengcsSource.dataSchemais set tocustomorcsv. Otherwise anINVALID_ARGUMENTerror is
returned. If you don't specifyautoGenerateIdsor set it tofalse, you must specifyidField. Otherwise the documents fail to
import.
ID_FIELD: optional. Specifies which fields are the
document IDs. For Cloud Storage source documents,idFieldspecifies the name in the JSON fields that are document IDs. For
example, if{"my_id":"some_uuid"}is the document ID field in one
of your documents, specify"idField":"my_id". This identifies all
JSON fields with the name"my_id"as document IDs.
Specify this field only when: (1)gcsSource.dataSchemais set tocustomorcsv, and (2)auto_generate_idsis set tofalseor
is unspecified. Otherwise anINVALID_ARGUMENTerror is returned.
Note that the value of the Cloud Storage JSON field must be of
string type, must be between 1-63 characters, and must conform toRFC-1034. Otherwise, the
documents fail to import.
Note that the JSON field name specified byid_fieldmust be of
string type, must be between 1 and 63 characters, and must conform
toRFC-1034. Otherwise, the
documents fail to import.
usingGoogle.Cloud.DiscoveryEngine.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedDataStoreServiceClientSnippets{/// <summary>Snippet for CreateDataStore</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidCreateDataStoreRequestObject(){// Create clientDataStoreServiceClientdataStoreServiceClient=DataStoreServiceClient.Create();// Initialize request argument(s)CreateDataStoreRequestrequest=newCreateDataStoreRequest{ParentAsCollectionName=CollectionName.FromProjectLocationCollection("[PROJECT]","[LOCATION]","[COLLECTION]"),DataStore=newDataStore(),DataStoreId="",CreateAdvancedSiteSearch=false,CmekConfigNameAsCmekConfigName=CmekConfigName.FromProjectLocation("[PROJECT]","[LOCATION]"),SkipDefaultSchemaCreation=false,};// Make the requestOperation<DataStore,CreateDataStoreMetadata>response=dataStoreServiceClient.CreateDataStore(request);// Poll until the returned long-running operation is completeOperation<DataStore,CreateDataStoreMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultDataStoreresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<DataStore,CreateDataStoreMetadata>retrievedResponse=dataStoreServiceClient.PollOnceCreateDataStore(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultDataStoreretrievedResult=retrievedResponse.Result;}}}
Import documents
usingGoogle.Cloud.DiscoveryEngine.V1;usingGoogle.LongRunning;usingGoogle.Protobuf.WellKnownTypes;publicsealedpartialclassGeneratedDocumentServiceClientSnippets{/// <summary>Snippet for ImportDocuments</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidImportDocumentsRequestObject(){// Create clientDocumentServiceClientdocumentServiceClient=DocumentServiceClient.Create();// Initialize request argument(s)ImportDocumentsRequestrequest=newImportDocumentsRequest{ParentAsBranchName=BranchName.FromProjectLocationDataStoreBranch("[PROJECT]","[LOCATION]","[DATA_STORE]","[BRANCH]"),InlineSource=newImportDocumentsRequest.Types.InlineSource(),ErrorConfig=newImportErrorConfig(),ReconciliationMode=ImportDocumentsRequest.Types.ReconciliationMode.Unspecified,UpdateMask=newFieldMask(),AutoGenerateIds=false,IdField="",ForceRefreshContent=false,};// Make the requestOperation<ImportDocumentsResponse,ImportDocumentsMetadata>response=documentServiceClient.ImportDocuments(request);// Poll until the returned long-running operation is completeOperation<ImportDocumentsResponse,ImportDocumentsMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultImportDocumentsResponseresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<ImportDocumentsResponse,ImportDocumentsMetadata>retrievedResponse=documentServiceClient.PollOnceImportDocuments(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultImportDocumentsResponseretrievedResult=retrievedResponse.Result;}}}
packagemainimport("context"discoveryengine"cloud.google.com/go/discoveryengine/apiv1"discoveryenginepb"cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=discoveryengine.NewDataStoreClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&discoveryenginepb.CreateDataStoreRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#CreateDataStoreRequest.}op,err:=c.CreateDataStore(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}
Import documents
packagemainimport("context"discoveryengine"cloud.google.com/go/discoveryengine/apiv1"discoveryenginepb"cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=discoveryengine.NewDocumentClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&discoveryenginepb.ImportDocumentsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#ImportDocumentsRequest.}op,err:=c.ImportDocuments(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}
importcom.google.cloud.discoveryengine.v1.CollectionName;importcom.google.cloud.discoveryengine.v1.CreateDataStoreRequest;importcom.google.cloud.discoveryengine.v1.DataStore;importcom.google.cloud.discoveryengine.v1.DataStoreServiceClient;publicclassSyncCreateDataStore{publicstaticvoidmain(String[]args)throwsException{syncCreateDataStore();}publicstaticvoidsyncCreateDataStore()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DataStoreServiceClientdataStoreServiceClient=DataStoreServiceClient.create()){CreateDataStoreRequestrequest=CreateDataStoreRequest.newBuilder().setParent(CollectionName.of("[PROJECT]","[LOCATION]","[COLLECTION]").toString()).setDataStore(DataStore.newBuilder().build()).setDataStoreId("dataStoreId929489618").setCreateAdvancedSiteSearch(true).setSkipDefaultSchemaCreation(true).build();DataStoreresponse=dataStoreServiceClient.createDataStoreAsync(request).get();}}}
Import documents
importcom.google.cloud.discoveryengine.v1.BranchName;importcom.google.cloud.discoveryengine.v1.DocumentServiceClient;importcom.google.cloud.discoveryengine.v1.ImportDocumentsRequest;importcom.google.cloud.discoveryengine.v1.ImportDocumentsResponse;importcom.google.cloud.discoveryengine.v1.ImportErrorConfig;importcom.google.protobuf.FieldMask;publicclassSyncImportDocuments{publicstaticvoidmain(String[]args)throwsException{syncImportDocuments();}publicstaticvoidsyncImportDocuments()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentServiceClientdocumentServiceClient=DocumentServiceClient.create()){ImportDocumentsRequestrequest=ImportDocumentsRequest.newBuilder().setParent(BranchName.ofProjectLocationDataStoreBranchName("[PROJECT]","[LOCATION]","[DATA_STORE]","[BRANCH]").toString()).setErrorConfig(ImportErrorConfig.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).setAutoGenerateIds(true).setIdField("idField1629396127").setForceRefreshContent(true).build();ImportDocumentsResponseresponse=documentServiceClient.importDocumentsAsync(request).get();}}}
/*** This snippet has been automatically generated and should be regarded as a code template only.* It will require modifications to work.* It may require correct/in-range values for request initialization.* TODO(developer): Uncomment these variables before running the sample.*//*** Resource name of the CmekConfig to use for protecting this DataStore.*/// const cmekConfigName = 'abc123'/*** DataStore without CMEK protections. If a default CmekConfig is set for* the project, setting this field will override the default CmekConfig as* well.*/// const disableCmek = true/*** Required. The parent resource name, such as* `projects/{project}/locations/{location}/collections/{collection}`.*/// const parent = 'abc123'/*** Required. The DataStore google.cloud.discoveryengine.v1.DataStore to* create.*/// const dataStore = {}/*** Required. The ID to use for the* DataStore google.cloud.discoveryengine.v1.DataStore, which will become* the final component of the* DataStore google.cloud.discoveryengine.v1.DataStore's resource name.* This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034)* standard with a length limit of 63 characters. Otherwise, an* INVALID_ARGUMENT error is returned.*/// const dataStoreId = 'abc123'/*** A boolean flag indicating whether user want to directly create an advanced* data store for site search.* If the data store is not configured as site* search (GENERIC vertical and PUBLIC_WEBSITE content_config), this flag will* be ignored.*/// const createAdvancedSiteSearch = true/*** A boolean flag indicating whether to skip the default schema creation for* the data store. Only enable this flag if you are certain that the default* schema is incompatible with your use case.* If set to true, you must manually create a schema for the data store before* any documents can be ingested.* This flag cannot be specified if `data_store.starting_schema` is specified.*/// const skipDefaultSchemaCreation = true// Imports the Discoveryengine libraryconst{DataStoreServiceClient}=require('@google-cloud/discoveryengine').v1;// Instantiates a clientconstdiscoveryengineClient=newDataStoreServiceClient();asyncfunctioncallCreateDataStore(){// Construct requestconstrequest={parent,dataStore,dataStoreId,};// Run requestconst[operation]=awaitdiscoveryengineClient.createDataStore(request);const[response]=awaitoperation.promise();console.log(response);}callCreateDataStore();
Import documents
/*** This snippet has been automatically generated and should be regarded as a code template only.* It will require modifications to work.* It may require correct/in-range values for request initialization.* TODO(developer): Uncomment these variables before running the sample.*//*** The Inline source for the input content for documents.*/// const inlineSource = {}/*** Cloud Storage location for the input content.*/// const gcsSource = {}/*** BigQuery input source.*/// const bigquerySource = {}/*** FhirStore input source.*/// const fhirStoreSource = {}/*** Spanner input source.*/// const spannerSource = {}/*** Cloud SQL input source.*/// const cloudSqlSource = {}/*** Firestore input source.*/// const firestoreSource = {}/*** AlloyDB input source.*/// const alloyDbSource = {}/*** Cloud Bigtable input source.*/// const bigtableSource = {}/*** Required. The parent branch resource name, such as* `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.* Requires create/update permission.*/// const parent = 'abc123'/*** The desired location of errors incurred during the Import.*/// const errorConfig = {}/*** The mode of reconciliation between existing documents and the documents to* be imported. Defaults to* ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL.*/// const reconciliationMode = {}/*** Indicates which fields in the provided imported documents to update. If* not set, the default is to update all fields.*/// const updateMask = {}/*** Whether to automatically generate IDs for the documents if absent.* If set to `true`,* Document.id google.cloud.discoveryengine.v1.Document.id s are* automatically generated based on the hash of the payload, where IDs may not* be consistent during multiple imports. In which case* ReconciliationMode.FULL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL* is highly recommended to avoid duplicate contents. If unset or set to* `false`, Document.id google.cloud.discoveryengine.v1.Document.id s have* to be specified using* id_field google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field,* otherwise, documents without IDs fail to be imported.* Supported data sources:* * GcsSource google.cloud.discoveryengine.v1.GcsSource.* GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource.* BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * SpannerSource google.cloud.discoveryengine.v1.SpannerSource.* * CloudSqlSource google.cloud.discoveryengine.v1.CloudSqlSource.* * FirestoreSource google.cloud.discoveryengine.v1.FirestoreSource.* * BigtableSource google.cloud.discoveryengine.v1.BigtableSource.*/// const autoGenerateIds = true/*** The field indicates the ID field or column to be used as unique IDs of* the documents.* For GcsSource google.cloud.discoveryengine.v1.GcsSource it is the key of* the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`.* For others, it may be the column name of the table where the unique ids are* stored.* The values of the JSON field or the table column are used as the* Document.id google.cloud.discoveryengine.v1.Document.id s. The JSON field* or the table column must be of string type, and the values must be set as* valid strings conform to RFC-1034 (https://tools.ietf.org/html/rfc1034)* with 1-63 characters. Otherwise, documents without valid IDs fail to be* imported.* Only set this field when* auto_generate_ids google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids* is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown.* If it is unset, a default value `_id` is used when importing from the* allowed data sources.* Supported data sources:* * GcsSource google.cloud.discoveryengine.v1.GcsSource.* GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource.* BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema* must be `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown.* * SpannerSource google.cloud.discoveryengine.v1.SpannerSource.* * CloudSqlSource google.cloud.discoveryengine.v1.CloudSqlSource.* * FirestoreSource google.cloud.discoveryengine.v1.FirestoreSource.* * BigtableSource google.cloud.discoveryengine.v1.BigtableSource.*/// const idField = 'abc123'/*** Optional. Whether to force refresh the unstructured content of the* documents.* If set to `true`, the content part of the documents will be refreshed* regardless of the update status of the referencing content.*/// const forceRefreshContent = true// Imports the Discoveryengine libraryconst{DocumentServiceClient}=require('@google-cloud/discoveryengine').v1;// Instantiates a clientconstdiscoveryengineClient=newDocumentServiceClient();asyncfunctioncallImportDocuments(){// Construct requestconstrequest={parent,};// Run requestconst[operation]=awaitdiscoveryengineClient.importDocuments(request);const[response]=awaitoperation.promise();console.log(response);}callImportDocuments();
fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdiscoveryengine# TODO(developer): Uncomment these variables before running the sample.# project_id = "YOUR_PROJECT_ID"# location = "YOUR_LOCATION" # Values: "global"# data_store_id = "YOUR_DATA_STORE_ID"defcreate_data_store_sample(project_id:str,location:str,data_store_id:str,)->str:# For more information, refer to:# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_storeclient_options=(ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")iflocation!="global"elseNone)# Create a clientclient=discoveryengine.DataStoreServiceClient(client_options=client_options)# The full resource name of the collection# e.g. projects/{project}/locations/{location}/collections/default_collectionparent=client.collection_path(project=project_id,location=location,collection="default_collection",)data_store=discoveryengine.DataStore(display_name="My Data Store",# Options: GENERIC, MEDIA, HEALTHCARE_FHIRindustry_vertical=discoveryengine.IndustryVertical.GENERIC,# Options: SOLUTION_TYPE_RECOMMENDATION, SOLUTION_TYPE_SEARCH, SOLUTION_TYPE_CHAT, SOLUTION_TYPE_GENERATIVE_CHATsolution_types=[discoveryengine.SolutionType.SOLUTION_TYPE_SEARCH],# TODO(developer): Update content_config based on data store type.# Options: NO_CONTENT, CONTENT_REQUIRED, PUBLIC_WEBSITEcontent_config=discoveryengine.DataStore.ContentConfig.CONTENT_REQUIRED,)request=discoveryengine.CreateDataStoreRequest(parent=parent,data_store_id=data_store_id,data_store=data_store,# Optional: For Advanced Site Search Only# create_advanced_site_search=True,)# Make the requestoperation=client.create_data_store(request=request)print(f"Waiting for operation to complete:{operation.operation.name}")response=operation.result()# After the operation is complete,# get information from operation metadatametadata=discoveryengine.CreateDataStoreMetadata(operation.metadata)# Handle the responseprint(response)print(metadata)returnoperation.operation.name
Import documents
fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdiscoveryengine# TODO(developer): Uncomment these variables before running the sample.# project_id = "YOUR_PROJECT_ID"# location = "YOUR_LOCATION" # Values: "global"# data_store_id = "YOUR_DATA_STORE_ID"# Examples:# - Unstructured documents# - `gs://bucket/directory/file.pdf`# - `gs://bucket/directory/*.pdf`# - Unstructured documents with JSONL Metadata# - `gs://bucket/directory/file.json`# - Unstructured documents with CSV Metadata# - `gs://bucket/directory/file.csv`# gcs_uri = "YOUR_GCS_PATH"# For more information, refer to:# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_storeclient_options=(ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")iflocation!="global"elseNone)# Create a clientclient=discoveryengine.DocumentServiceClient(client_options=client_options)# The full resource name of the search engine branch.# e.g. projects/{project}/locations/{location}/dataStores/{data_store_id}/branches/{branch}parent=client.branch_path(project=project_id,location=location,data_store=data_store_id,branch="default_branch",)request=discoveryengine.ImportDocumentsRequest(parent=parent,gcs_source=discoveryengine.GcsSource(# Multiple URIs are supportedinput_uris=[gcs_uri],# Options:# - `content` - Unstructured documents (PDF, HTML, DOC, TXT, PPTX)# - `custom` - Unstructured documents with custom JSONL metadata# - `document` - Structured documents in the discoveryengine.Document format.# - `csv` - Unstructured documents with CSV metadatadata_schema="content",),# Options: `FULL`, `INCREMENTAL`reconciliation_mode=discoveryengine.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL,)# Make the requestoperation=client.import_documents(request=request)print(f"Waiting for operation to complete:{operation.operation.name}")response=operation.result()# After the operation is complete,# get information from operation metadatametadata=discoveryengine.ImportDocumentsMetadata(operation.metadata)# Handle the responseprint(response)print(metadata)
require"google/cloud/discovery_engine/v1"### Snippet for the create_data_store call in the DataStoreService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DiscoveryEngine::V1::DataStoreService::Client#create_data_store.#defcreate_data_store# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DiscoveryEngine::V1::DataStoreService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DiscoveryEngine::V1::CreateDataStoreRequest.new# Call the create_data_store method.result=client.create_data_storerequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend
Import documents
require"google/cloud/discovery_engine/v1"### Snippet for the import_documents call in the DocumentService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#import_documents.#defimport_documents# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest.new# Call the import_documents method.result=client.import_documentsrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend
The following procedure describes how to create a data connector that associates
a Cloud Storage location with a Vertex AI Search data
connector and how to specify a folder or file in that location for the data
store that you want to create. Data stores that are children of data connectors
are calledentitydata stores.
Data is synced periodically to the entity data store. You can specify
synchronization daily, every three days, or every five days.
Console
In the Google Cloud console, go to theAI Applicationspage.
Select theSynchronization frequency, how often you want the
Vertex AI Search connector to sync with the Cloud Storage
location. You can change the frequency later.
In theSelect a folder or file you want to importsection, selectFolderorFile.
ClickBrowseand choose the data you haveprepared for ingesting, and then clickSelect.
Alternatively, enter the location directly in thegs://field.
ClickContinue.
Choose a region for your data connector.
Enter a name for your data connector.
Optional: If you selected unstructured documents, you can select parsing and
chunking options for your documents. To compare parsers, seeParse
documents. For information about chunking seeChunk documents for
RAG.
To select a parser, expandDocument processing optionsand specify the
parser options that you want to use.
ClickCreate.
You have now created a data connector, which will periodically sync data
with the Cloud Storage location. You have also created an entity
data store, which is namedgcs_store.
To check the status of your ingestion, go to theData Storespage and
click your data connector name to see details about it on itsDatapage
Data ingestion activitytab. When the status column on theData
ingestion activitytab changes fromIn progresstosucceeded, the
first ingestion is complete.
Depending on the size of your data, ingestion can take several
minutes to several hours.
After you set up your data source and import data the first time, data is
synced from that source at a frequency that you select during setup.
About an hour after the data connector is created, the first sync occurs.
The next sync then occurs around 24 hours, 72 hours,
or 120 hours later.
DATA_STORE_ID: the ID of the recommendations data store that you want to create. This ID can contain only lowercase
letters, digits, underscores, and hyphens.
DATA_STORE_DISPLAY_NAME: the display name of the recommendations data store that you want to create.
Optional: Provide your own schema. When you provide a schema, you typically
get better results. For more information, seeProvide or auto-detect a schema.
ReplaceJSON_DOCUMENT_STRINGwith the JSON document as a
single string. This must conform to the JSON schema that you
provided in the previous step—for example:
ReplaceJSON_DOCUMENT_OBJECTwith the JSON document as a
JSON object. This must conform to the JSON schema that you provided
in the previous step—for example:
To preview how your recommendations appear after your app and data store are
set up, seeGet recommendations.
Create a data store using Terraform
You can use Terraform to create an empty data store. After the empty data store
is created, you can ingest data into the data store using the Google Cloud console
or API commands.
[[["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-04 UTC."],[[["\u003cp\u003eThis document guides you through creating a data store and ingesting data for generic recommendations, offering options to use BigQuery, Cloud Storage, or direct API uploads.\u003c/p\u003e\n"],["\u003cp\u003eData ingestion involves preparing your data, which is linked for review, before proceeding with the creation of a data store through the Google Cloud console or via API commands for both BigQuery and Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eFor BigQuery, data can be imported using the console or through REST API commands, and it is possible to set a custom schema for better results.\u003c/p\u003e\n"],["\u003cp\u003eFor Cloud Storage, the console or REST API can be used to import data, with options to specify data schema, reconciliation mode, and whether to auto-generate IDs.\u003c/p\u003e\n"],["\u003cp\u003eYou have the option of creating an empty data store using Terraform, after which, data ingestion can be performed via the Google Cloud console or API commands.\u003c/p\u003e\n"]]],[],null,[]]