/collection/info 接口用于查询指定数据集 Collection 的详情信息。
请求向量数据库 VikingDB 的 OpenAPI 接口时,需要构造签名进行鉴权,详细的 OpenAPI 签名调用方法请参见 API签名调用指南。
URI | /api/collection/info | 统一资源标识符 |
|---|---|---|
方法 | GET | 客户端对向量数据库服务器请求的操作类型 |
请求头 | Content-Type: application/json | 请求消息类型 |
Authorization: HMAC-SHA256 *** | 鉴权 |
参数 | 类型 | 是否必选 | 参数说明 |
|---|---|---|---|
collection_name/collection_alias | string | 是 | 指定查询的 Collection 名称/别名。
|
resource_id | string | 否 | 资源ID;资源 ID 可通过相应资源的创建接口返回结果获取,也可在资源详情中查看。 |
参数 | 参数说明 |
|---|---|
code | 状态码 |
message | 返回信息 |
request_id | 标识每个请求的唯一标识符 |
data | Collection详情,详见 Collection 参数说明。 |
参数 | 子参数 | 类型 | 参数说明 |
|---|---|---|---|
collection_name | -- | string | 显示查询的 Collection 名称。 |
description | -- | string | 显示查询的 Collection 的描述。 |
collection_aliases | -- | array | 显示查询的别名列表。 |
resource_id | -- | string | 资源ID |
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 | -- | 纯文本。 | |
stat | data_number | 数值 | 数据量条数,注意:
|
data_storage | 数值 | 数据存储大小(单位为: 字节),注意:
| |
index_names | -- | array | 显示 Collection 相关联的索引名字列表。 |
index_num | -- | int | 显示 Collection 相关联的索引个数。 |
create_time | -- | string | 数据集创建时间。 |
update_time | -- | string | 数据集更新时间。 |
update_person | -- | string | 数据集更新人。 |
状态码 | http状态码 | 返回信息 | 状态码说明 |
|---|---|---|---|
0 | 200 | get collection success | 查询指定 Collection 的详情成功。 |
1000005 | 404 | collection not exist | Collection 不存在。 |
1000003 | 400 | invalid request:%s | 非法参数:
|
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/info \ -d '{ "collection_name": "test_name" }'
执行成功返回:
HTTP/1.1 200 OK Content-Length: 43 Content-Type: application/json { "code":0, "message":"success", "request_id":"021695029537650fd001de666660000000000000000000230da93", "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": "dense_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": [ "test_index", "test_index_1" ], "index_num": 2, "stat":{"data_number":20,"data_storage":2440}, "create_time": "2023-11-21 12:22:57", "update_time": "2023-11-22 11:15:45", "update_person": "zhangsan" } }
执行失败返回:
HTTP/1.1 404 Not Found Content-Length: 43 Content-Type: application/json {"code":1000005, "message":"collection not exist", "request_id":"021695029537650fd001de666660000000000000000000230da93"}
请求时使用 collection_name 或 collection_alias 定位 Collection:两者均为 string,且必须且只能传一个;不要发送名为 collection_name/collection_alias 的 JSON Key。
pipeline_name 类型为 string,表示 Collection 绑定的向量化 Pipeline 名称;未绑定 Pipeline 时该字段为空或不返回。
| 错误码 | 处理建议 |
|---|---|
1000001 | 检查 AK/SK、签名时间和 Authorization 请求头,并按 API 签名调用指南重新生成签名。 |
1000002 | 检查 IAM 用户是否具有目标项目和 VikingDB 资源权限,缺少权限时由管理员授权。 |
1000003 | 根据错误消息检查必填参数、类型、枚举值和数值范围。 |
1000005 | 检查 collection_name 是否拼写正确、是否位于当前项目且尚未删除。 |
1000008 | 检查 index_name 是否正确、索引是否已创建并处于可用状态。 |
1000011 | 检查数据主键是否存在于目标 Collection;不存在时先写入数据。 |
完整触发条件参见向量库 V1 错误码。