接口定义
list_collections() 接口用于查询指定 Database 中所有的 Collection。
def list_collections(self, timeout: Optional[float] = None) -> List[Collection]
使用示例
# 指定 Base 类数据库db = client.database('db-test')# 查询 Base 类数据库下的集合列表coll_list = db.list_collections()for col in coll_list:print(vars(col))
入参描述
参数名 | 是否必选 | 参数含义 | 配置方法 |
timeout | 否 | 请求超时时间。 | 单位:秒。 默认值:VectorDBClient() 接口配置的 timeout 时长。 取值范围:大于等于0。 |
出参描述
{'database': 'db-test','collection': 'book-emb','replicaNum': 0,'shardNum': 1,'indexes': [{'fieldName': 'vector','fieldType': 'vector','indexType': 'HNSW','metricType': 'COSINE','dimension': 768,'params': {'M': 16,'efConstruction': 200},'indexedCount': 0},{'fieldName': 'bookName','fieldType': 'string','indexType': 'filter'},{'fieldName': 'tags','fieldType': 'string','indexType': 'filter'},{'fieldName': 'id','fieldType': 'string','indexType': 'primaryKey'},{'fieldName': 'author','fieldType': 'string','indexType': 'filter'},{'fieldName': 'sparse_vector','fieldType': 'sparseVector','indexType': 'inverted','metricType': 'IP'}],'embedding': {'status': 'enabled','field': 'text','model': 'bge-base-zh','vectorField': 'vector'},'description': 'this is a collection of test embedding','createTime': '2024-09-09 17:28:10','documentCount': 0,'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。 |
| | filedType | 显示该索引对象的数据类型,固定为 string。 |
| | indexType | 该参数固定显示为 primaryKey。即该索引对象以 id 为主键构建索引。 |
| 向量索引 | fieldName | 标识索引对象为 vector 字段名,固定为 vector。 |
| | filedType | 指定索引对象为 vector 字段的数据类型,固定为 vector。 |
| | indexType | |
| | indexedCount | 索引对象为 vector 字段的文档数量。 |
| | dimension | 显示索引对象为 vector 的向量维度。 |
| | metricType | 显示索引象为 vector 的向量之间的距离度量的算法。 |
| | params | 显示索引类型对应的参数。 |
| Filter 索引 | fieldName | 自定义扩展的可设置 Filter 表达式的字段名。例如:page、author。 |
| | filedType | 显示字段的数据类型。 |
| | indexType | |
| 稀疏向量索引 | 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 是否在重建索引。 ready:表示当前 Collection 已准备就绪,可正常使用。 training:表示当前 Collection 正在进行数据训练,即训练模型以生成向量数据。 building:表示当前 Collection 正在重建索引,即将生成的向量数据存储到新的索引中。 failed:重建索引失败,可能会影响集合读写操作。 |
| | startTime | 重建索引开始的时间。 |