Documents

File Search API 会将您的原始源文件或文档引用为临时 File 对象。

方法:fileSearchStores.documents.delete

删除 Document

端点

delete https://generativelanguage.googleapis.com/v1beta/{name=fileSearchStores/*/documents/*}

路径参数

name string

必需。要删除的 Document 的资源名称。示例:fileSearchStores/my-file-search-store-123/documents/the-doc-abc 格式为 fileSearchStores/{filesearchstore}/documents/{document}

查询参数

force boolean

可选。如果设置为 true,则与此 Document 相关的所有 Chunk 和对象也会被删除。

如果为 false(默认值),则当 Document 包含任何 Chunk 时,系统会返回 FAILED_PRECONDITION 错误。

请求正文

请求正文必须为空。

响应正文

如果成功,则响应正文为空的 JSON 对象。

方法:fileSearchStores.documents.get

获取有关特定 Document 的信息。

端点

get https://generativelanguage.googleapis.com/v1beta/{name=fileSearchStores/*/documents/*}

路径参数

name string

必需。要检索的 Document 的名称。示例:fileSearchStores/my-file-search-store-123/documents/the-doc-abc 格式为 fileSearchStores/{filesearchstore}/documents/{document}

请求正文

请求正文必须为空。

响应正文

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

方法:fileSearchStores.documents.list

列出 Corpus 中的所有 Document

端点

get https://generativelanguage.googleapis.com/v1beta/{parent=fileSearchStores/*}/documents

路径参数

parent string

必需。包含 DocumentFileSearchStore 的名称。示例:fileSearchStores/my-file-search-store-123 格式为 fileSearchStores/{filesearchstore}

查询参数

pageSize integer

可选。要返回的 Document 的数量上限(每页)。服务返回的 Document 数量可能较少。

如果未指定,则最多返回 10 个 Document。每页的上限为 20 个 Document

pageToken string

可选。从之前的 documents.list 调用接收的页面令牌。

在下一个请求中提供响应中返回的 nextPageToken 作为实参,以检索下一页。

进行分页时,提供给 documents.list 的所有其他参数必须与提供页面令牌的调用匹配。

请求正文

请求正文必须为空。

响应正文

来自 documents.list 的响应,包含分页的 Document 列表。Document 按升序 document.create_time 排序。

如果成功,响应正文将包含结构如下的数据:

字段
documents[] object (Document)

返回的 Document

nextPageToken string

可作为 pageToken 发送并用于检索下一页的令牌。如果省略此字段,则没有更多页面。

JSON 表示法
{
  "documents": [
    {
      object (Document)
    }
  ],
  "nextPageToken": string
}

REST 资源:fileSearchStores.documents

资源:Document

DocumentChunk 的集合。

字段
name string

不可变。标识符。Document 资源名称。ID(不含“fileSearchStores/*/documents/”前缀的名称)最多可包含 40 个字符,这些字符可以是小写字母数字字符或短划线 (-)。ID 不能以短划线开头或结尾。如果创建时的名称为空,系统会根据 displayName 派生出一个唯一名称,并附加一个 12 字符的随机后缀。示例:fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c

displayName string

可选。Document 的人类可读显示名称。显示名称的长度不得超过 512 个字符(包括空格)。示例:“语义检索器文档”

customMetadata[] object (CustomMetadata)

可选。用户提供的自定义元数据,以键值对的形式存储,用于查询。一个 Document 最多可以有 20 个 CustomMetadata

updateTime string (Timestamp format)

仅限输出。上次更新 Document 时的时间戳。

采用 RFC 3339 标准,生成的输出将始终进行 Z 规范化(即转换为 UTC 零时区格式并在末尾附加 Z),并使用 0、3、6 或 9 个小数位。不带“Z”的偏差时间也是可以接受的。示例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z""2014-10-02T15:01:23+05:30"

createTime string (Timestamp format)

仅限输出。Document 的创建时间戳。

采用 RFC 3339 标准,生成的输出将始终进行 Z 规范化(即转换为 UTC 零时区格式并在末尾附加 Z),并使用 0、3、6 或 9 个小数位。不带“Z”的偏差时间也是可以接受的。示例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z""2014-10-02T15:01:23+05:30"

state enum (State)

仅限输出。Document 的当前状态。

sizeBytes string (int64 format)

仅限输出。提取到文档中的原始字节的大小。

mimeType string

仅限输出。相应文档的 MIME 类型。

JSON 表示法
{
  "name": string,
  "displayName": string,
  "customMetadata": [
    {
      object (CustomMetadata)
    }
  ],
  "updateTime": string,
  "createTime": string,
  "state": enum (State),
  "sizeBytes": string,
  "mimeType": string
}

CustomMetadata

用户提供的元数据,以键值对的形式存储。

字段
key string

必需。要存储的元数据的键。

value Union type
value 只能是下列其中一项:
stringValue string

要存储的元数据的字符串值。

stringListValue object (StringList)

要存储的元数据的 StringList 值。

numericValue number

要存储的元数据的数值。

JSON 表示法
{
  "key": string,

  // value
  "stringValue": string,
  "stringListValue": {
    object (StringList)
  },
  "numericValue": number
  // Union type
}

StringList

分配给单个元数据键的用户提供的字符串值。

字段
values[] string

要存储的元数据的字符串值。

JSON 表示法
{
  "values": [
    string
  ]
}

Document 生命周期中的状态。

枚举
STATE_UNSPECIFIED 默认值。如果省略状态,则使用此值。
STATE_PENDING 部分 Document 正在处理中(嵌入和向量存储)。Chunks
STATE_ACTIVE Document 的所有 Chunks 都已处理完毕,可供查询。
STATE_FAILED Document 中的部分 Chunks 处理失败。