Method: projects.locations.dataStores.branches.documents.import

批量导入多个 Document。请求处理可以是同步的。创建不存在的商品。

注意:部分 Document 可能已成功更新。

HTTP 请求

POST https://discoveryengine.googleapis.com/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import

网址采用 gRPC 转码语法。

路径参数

参数
parent

string

必需。父分支资源名称,例如 projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}/branches/{branch}。需要创建/更新权限。

请求正文

请求正文中包含结构如下的数据:

JSON 表示法
{
  "errorConfig": {
    object (ImportErrorConfig)
  },
  "reconciliationMode": enum (ReconciliationMode),
  "updateMask": string,
  "autoGenerateIds": boolean,
  "idField": string,
  "forceRefreshContent": boolean,

  // Union field source can be only one of the following:
  "inlineSource": {
    object (InlineSource)
  },
  "gcsSource": {
    object (GcsSource)
  },
  "bigquerySource": {
    object (BigQuerySource)
  },
  "fhirStoreSource": {
    object (FhirStoreSource)
  },
  "spannerSource": {
    object (SpannerSource)
  },
  "cloudSqlSource": {
    object (CloudSqlSource)
  },
  "firestoreSource": {
    object (FirestoreSource)
  },
  "alloyDbSource": {
    object (AlloyDbSource)
  },
  "bigtableSource": {
    object (BigtableSource)
  }
  // End of list of possible types for union field source.
}
字段
errorConfig

object (ImportErrorConfig)

导入期间发生错误的所需位置。

reconciliationMode

enum (ReconciliationMode)

现有文档与要导入的文档之间的调和模式。默认值为 ReconciliationMode.INCREMENTAL

updateMask

string (FieldMask format)

指示要更新所提供的导入文档中的哪些字段。如果未设置,则默认更新所有字段。

这是完全限定字段名称的逗号分隔列表。示例:"user.displayName,photo"

autoGenerateIds

boolean

是否在缺少 ID 的情况下自动为文档生成 ID。

如果设置为 true,系统会根据载荷的哈希自动生成 Document.id,但多次导入期间 ID 可能不一致。在这种情况下,强烈建议使用 ReconciliationMode.FULL 以避免内容重复。如果未设置或设置为 false,则必须使用 idField 指定 Document.id,否则,没有 ID 的文档将无法导入。

支持的数据源:

idField

string

该字段用于指明要用作文档唯一 ID 的 ID 字段或列。

对于 GcsSource,它是 JSON 字段的键。例如,JSON 的 my_id{"my_id": "some_uuid"}。对于其他用户,这可能是存储唯一 ID 的表的列名。

JSON 字段或表格列的值用作 Document.id。JSON 字段或表列必须为字符串类型,并且值必须设置为符合 RFC-1034 的有效字符串,长度为 1-63 个字符。否则,没有有效 ID 的文档将无法导入。

仅当 autoGenerateIds 未设置或设置为 false 时,才设置此字段。否则,系统会抛出 INVALID_ARGUMENT 错误。

如果未设置,则在从允许的数据源导入时使用默认值 Id

支持的数据源:

forceRefreshContent

boolean

可选。是否强制刷新文档的非结构化内容。

如果设置为 true,则无论引用内容是否已更新,系统都会刷新文档的内容部分。

联合字段 source。必需。输入的来源。source 只能是下列其中一项:
inlineSource

object (InlineSource)

文档的输入内容的内嵌来源。

gcsSource

object (GcsSource)

输入内容所在的 Cloud Storage 位置。

bigquerySource

object (BigQuerySource)

BigQuery 输入源。

fhirStoreSource

object (FhirStoreSource)

FhirStore 输入源。

spannerSource

object (SpannerSource)

Spanner 输入源。

cloudSqlSource

object (CloudSqlSource)

Cloud SQL 输入源。

firestoreSource

object (FirestoreSource)

Firestore 输入源。

alloyDbSource

object (AlloyDbSource)

AlloyDB 输入源。

bigtableSource

object (BigtableSource)

Cloud Bigtable 输入源。

响应正文

如果成功,则响应正文包含一个 Operation 实例。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/discoveryengine.readwrite

如需了解详情,请参阅 Authentication Overview

IAM 权限

需要拥有 parent 资源的以下 IAM 权限:

  • discoveryengine.documents.import

如需了解详情,请参阅 IAM 文档