查询 Collection 列表

最近更新时间:2024-05-15 10:17:31

我的收藏

功能介绍

list_collections() 接口用于查询指定 Database 中所有的 Collection。

请求示例

import tcvectordb
from tcvectordb.model.enum import ReadConsistency
#create a database client object
client = tcvectordb.VectorDBClient(url='http://10.0.X.X', username='root', key='eC4bLRy2va******************************', timeout=30)
# 指定 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": 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": "db-test",
"collection": "book-vector",
"replicaNum": 2,
"shardNum": 1,
"description": "this is a collection of test embedding",
"indexes": [
{
"fieldName": "author",
"fieldType": "string",
"indexType": "filter"
},
{
"fieldName": "id",
"fieldType": "string",
"indexType": "primaryKey"
},
{
"fieldName": "vector",
"fieldType": "vector",
"indexType": "HNSW",
"dimension": 3,
"metricType": "COSINE",
"params": {
"M": 16,
"efConstruction": 200
},
"indexedCount": 3
},
{
"fieldName": "bookName",
"fieldType": "string",
"indexType": "filter"
}
],
"embedding": {
"status": "disabled"
},
"documentCount": 3,
"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
显示索引类型。当前所支持的索引类型及具体索引方式,请参见设计模型中的 Index
indexedCount
索引对象为 vector 字段的文档数量。
dimension
显示索引对象为 vector 的向量维度。
metricType
显示索引象为 vector 的向量之间的距离度量的算法。
params
显示索引类型对应的参数。
Filter 索引
fieldName
自定义扩展的可设置 Filter 表达式的字段名。例如:page、author。
filedType
显示字段的数据类型。
indexType
标识自定义字段是否可以设置 Filter 表达式,固定为 filter。具体信息,请参见 混合检索
embedding
Embedding 相关参数
status
说明该 Collection 是否配置 Embedding 模型。
enabled:已配置。
disabled:未配置。
field
显示 Embedding 模型输入文本的字段名。
model
Embedding 模型的名称。
vectorField
显示 Embedding 模型向量字段名。
alias
集合别名
-
集合别名。
indexStatus
集合重建索引相关参数
status
标识当前 Collection 是否在重建索引。
ready:表示当前 Collection 已准备就绪,可正常使用。
training data:表示当前 Collection 正在进行数据训练,即训练模型以生成向量数据。
building index:表示当前 Collection 正在重建索引,即将生成的向量数据存储到新的索引中。
failed:重建索引失败,可能会影响集合读写操作。
startTime
重建索引开始的时间。