/collection/list 接口用于查询数据集 Collection 列表。
请求向量数据库 VikingDB 的 OpenAPI 接口时,需要构造签名进行鉴权,详细的 OpenAPI 签名调用方法请参见 API签名调用指南。
URI | /api/collection/list | 统一资源标识符 |
|---|---|---|
请求方法 | GET | 客户端对向量数据库服务器请求的操作类型 |
请求头 | Content-Type: application/json | 请求消息类型 |
Authorization: HMAC-SHA256 *** | 鉴权 |
无。
参数 | 参数说明 |
|---|---|
code | 状态码 |
message | 返回信息 |
request_id | 标识每个请求的唯一标识符 |
data | Collection 详情列表,每个 Collection 包含的字段详见 Collection 参数说明。 |
参数 | 子参数 | 类型 | 参数说明 |
|---|---|---|---|
collection_name | string | 显示查询的 Collection 名称。 | |
description | string | 显示查询的 Collection 的描述。 | |
project | string | 不为空时,返回指定project下的数据集 | |
primary_key | string | 显示以下定义的某个 field_name 作为主键字段名称。主键的字段类型必须是int64 类型 / string 类型。 | |
fields | field_name | string | 显示自定义字段的名称。 |
field_type | string | 显示自定义字段类型,可选值包含 int64、float32、string、bool、list | |
default_val | 和field_type一致 | 显示自定义字段默认值。 | |
dim | int | 显示自定义字段向量维度。 | |
pipeline_name | 纯文本。 | ||
index_names | array | 显示 Collection 相关联的索引名字列表。 | |
index_num | int | 显示 Collection 相关联的索引个数。 | |
create_time | string | 数据集创建时间。 | |
update_time | string | 数据集更新时间。 | |
update_person | string | 数据集更新人。 |
状态码 | http状态码 | 返回信息 | 状态码说明 |
|---|---|---|---|
0 | 200 | success | 查询 Collection 列表成功。 |
1000001 | 401 | unauthorized | 请求头中缺乏鉴权信息。 |
1000002 | 403 | no permission | 权限不足。 |
curl -i -X GET \ -H 'Content-Type: application/json' \ -H 'Authorization: HMAC-SHA256 ***' \ https://api-vikingdb.volces.com/api/collection/list
执行成功返回:
HTTP/1.1 200 OK Content-Length: 43 Content-Type: application/json { "code":0, "message":"success", "request_id":"021695029748777fd001de6666600000000000000000002887b8d", "data": [ { "collection_name": "test_name", "description": "test dataset", "primary_key": "id", "fields": [ { "field_name": "id", "field_type": "int64" }, { "field_name": "text", "field_type": "string", "default_val": "" }, { "field_name": "vector_field", "field_type": "vector", "dim": 768 }, { "field_name": "sparse_vector_field", "field_type": "sparse_vector" }, { "field_name": "time", "field_type": "int64", "default_val": 0 }, { "field_name": "author", "field_type": "string", "default_val": "null" } ], "index_names": [ "index1", "index2" ], "index_num": 2, "create_time": "2023-11-21 12:22:57", "update_time": "2023-11-22 11:15:45", "update_person": "zhangsan" }, { "collection_name": "test_name2", "description": "test dataset 2", "primary_key": "id", "fields": [ { "field_name": "id", "field_type": "int64" }, { "field_name": "vector_field", "field_type": "vector", "dim": 768 } ], "index_names": [ "index3", "index4" ], "index_num": 2, "create_time": "2023-11-21 10:22:57", "update_time": "2023-11-22 11:15:45", "update_person": "zhangsan" } ] }
执行失败返回:
HTTP/1.1 401 OK Content-Length: 43 Content-Type: application/json {"code":1000001,"message":"unauthorized","request_id":"021695029748777fd001de666660000000000000"}
| 字段 | 类型 | 含义 |
|---|---|---|
code | int | 业务状态码;成功时为 0。 |
message | string | 状态说明或错误信息。 |
request_id | string | 请求唯一标识,用于问题排查。 |
data | object / array | 接口业务数据;没有业务数据时可为空。 |
列表接口的 data 为 array<object>,列表元素类型与对应 Collection 或 Index 详情对象一致;total 为 int64。
project 是返回参数,类型为 string,表示该 Collection 所属的项目名称;它不是本接口新增的请求参数。
pipeline_name 类型为 string,表示 Collection 绑定的向量化 Pipeline 名称;未绑定 Pipeline 时该字段为空或不返回。
create_time 类型为 string,表示资源创建时间,格式为 YYYY-MM-DD HH:mm:ss,时区为 Asia/Shanghai(UTC+8)。
| 错误码 | 处理建议 |
|---|---|
1000001 | 检查 AK/SK、签名时间和 Authorization 请求头,并按 API 签名调用指南重新生成签名。 |
1000002 | 检查 IAM 用户是否具有目标项目和 VikingDB 资源权限,缺少权限时由管理员授权。 |
1000003 | 根据错误消息检查必填参数、类型、枚举值和数值范围。 |
1000005 | 检查 collection_name 是否拼写正确、是否位于当前项目且尚未删除。 |
1000008 | 检查 index_name 是否正确、索引是否已创建并处于可用状态。 |
1000011 | 检查数据主键是否存在于目标 Collection;不存在时先写入数据。 |
完整触发条件参见向量库 V1 错误码。