查询指定 Collection

最近更新时间:2025-11-07 12:10:01

我的收藏

接口定义

describe_collection() 接口用于查询指定 Collection 的信息。
def describe_collection(
database_name: str,
collection_name: str,
timeout: float | None = None
) -> RPCCollection

使用示例

# 查询 Base 类数据库下的集合
res = client.describe_collection(database_name='db-test', collection_name='book-emb')
print(vars(res))

入参描述

参数名
是否必选
参数含义
配置方法
database_name
指定数据库名
Database 命名要求如下:
只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。
长度要求:[1,128]。
collection_name
指定 Collection 的名称。
Collection 命名要求如下:
只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。
长度要求:[1,128]。
timeout
请求超时时长。
单位:秒。
默认值:VectorDBClient() 接口配置的 timeout 时长。
取值范围:大于等于0。

出参描述

{
"database": "db-test",
"collection": "book-emb",
"replicaNum": 2,
"shardNum": 1,
"description": "this is a collection of test embedding",
"indexes": [
{
"fieldName": "id",
"fieldType": "string",
"indexType": "primaryKey"
},
{
"fieldName": "author",
"fieldType": "string",
"indexType": "filter"
},
{
"fieldName": "vector",
"fieldType": "vector",
"indexType": "HNSW",
"dimension": 768,
"metricType": "COSINE",
"params": {
"M": 16,
"efConstruction": 200
},
"indexedCount": 3
},
{
"fieldName": "bookName",
"fieldType": "string",
"indexType": "filter"
},
{
"fieldName": "tags",
"fieldType": "string",
"indexType": "filter"
}
],
"embedding": {
"status": "enabled",
"field": "text",
"model": "bge-base-zh",
"vectorField": "vector"
},
"documentCount": 3,
"alias": [
"alias-book-emb"
],
"indexStatus": {
"status": "ready",
"startTime": ""
}
}
参数(一级)
参数(二级)
参数含义
database
-
-
Collection 所在的 Database 名称。
collection
-
-
Collection 的名称。
replicaNum
-
-
Collection 的副本数。
shardNum
-
-
Collection 的分片数。
createTime
-
-
Collection 的创建时间。
description
-
-
Collection 的描述信息。
documentCount
-
-
Collection 中存储的 Document 数量。
indexes
主键索引
fieldName
标识索引对象为 id
fieldType
主键索引数据类型,固定为 string。
indexType
该参数固定显示为 primaryKey。即该索引对象以 id 为主键构建索引。
向量索引
fieldName
标识索引字段,固定为 vector
fieldType
向量索引的数据类型,固定为 vector
indexType
向量索引的索引类型。具体信息,请参见 索引类型
indexedCount
向量索引的文档数量。
dimension
向量维度。
metricType
向量之间的距离度量的算法。
params
向量索引类型对应的参数。
Filter 索引
fieldName
自定义扩展的可设置 Filter 表达式的字段名。例如:page、author。
fieldType
字段的数据类型。
indexType
标识自定义字段是否可以设置 Filter 表达式,固定为 filter
稀疏向量索引
fieldName
稀疏向量字段名,固定为:sparse_vector。
fieldType
稀疏向量数据类型,固定为:sparseVector
indexType
索引类型,固定为:inverted
metricType
稀疏向量间的距离度量的算法。
embedding
Embedding 相关参数
status
说明该 Collection 是否配置 Embedding 模型。
enabled:已配置。
disabled:未配置。
field
Embedding 模型输入文本的字段名。
model
Embedding 模型的名称。
vectorField
显示 Embedding 模型向量字段名。
alias
集合别名
-
集合别名。
indexStatus
集合重建索引相关参数
status
标识当前 Collection 构建索引的状态。
initial:索引已创建但尚未构建,处于初始状态。
ready:索引构建成功且已就绪,可正常执行操作。
training:正在训练机器学习模型以生成向量数据。
building:正在构建向量索引结构并存储向量数据。
building_scalar:正在构建标量索引。
building_sparse:正在构建稀疏向量索引。
failed:索引构建失败,需修复后方可正常操作。
startTime
重建索引开始的时间。