查询指定 Collection 配置

最近更新时间:2024-09-04 11:33:53

我的收藏

功能介绍

DescribeCollection()用于查找指定 Collection 的配置信息。

请求示例

如下示例,通过接口 DescribeCollection() 查找 go-sdk-test-coll 的集合配置信息。
var (
ctx = context.Background()
database = "go-sdk-test-db"
collectionName = "go-sdk-test-coll"
)

db := client.Database(database)
result, _ := db.DescribeCollection(ctx, collectionName)
data, _ := json.Marshal(result)
log.Printf("DescribeCollection result: %+v", string(data))
参数名
是否必选
参数含义
配置方法及要求
collectionName
指定所需查询的 Collection 名称。
使用 ListCollection() 获取指定数据库名下的 Collection 列表,复制需查询的集合名。

返回信息

{
"databaseName": "go-sdk-test-db",
"collectionName": "go-sdk-test-coll",
"documentCount": 0,
"alias": null,
"shardNum": 1,
"replicasNum": 0,
"indexes": {
"VectorIndex": [{
"FieldName": "vector",
"FieldType": "vector",
"ElemType": "",
"IndexType": "HNSW",
"Dimension": 3,
"MetricType": "COSINE",
"IndexedCount": 0,
"Params": {
"M": 16,
"EfConstruction": 200
}
}],
"FilterIndex": [{
"FieldName": "id",
"FieldType": "string",
"ElemType": "",
"IndexType": "primaryKey"
}, {
"FieldName": "tag",
"FieldType": "array",
"ElemType": "",
"IndexType": "filter"
}, {
"FieldName": "page",
"FieldType": "uint64",
"ElemType": "",
"IndexType": "filter"
}, {
"FieldName": "bookName",
"FieldType": "string",
"ElemType": "",
"IndexType": "filter"
}]
},
"indexStatus": {
"Status": "ready",
"StartTime": "0001-01-01T00:00:00Z"
},
"embedding": {},
"description": "test collection",
"size": 0,
"createTime": "2023-12-20T17:26:12Z"
}
参数
子参数
子参数
参数含义
databaseName
-
-
显示 Collection 所在的 Database 名称。
collectionName
-
-
显示 Collection 的名称。
replicaNum
-
-
显示 Collection 的副本数。
shardNum
-
-
显示 Collection 的分片数。
createTime
-
-
显示 Collection 的创建时间。
description
-
-
显示 Collection 的描述信息。
documentCount
-
-
返回 Collection 中存储的 Document 数量。
indexes
VectorIndex
fieldName
向量数据索引的字段名,固定为 vector
filedType
vector 字段的数据类型,固定为 vector
indexType
显示索引类型。
indexedCount
向量索引的文档数量。
dimension
向量数据维度。
metricType
目标向量数据与查询的向量数据相似性计算方法。
params
向量索引类型对应的相关参数。
FilterIndex
fieldName
id:默认对 id 构建主键 Filter 索引,对应 indexType 为 primaryKey。
page、bookName、tag:自定义扩展的设置为 Filter 表达式的字段名。
filedType
Filter 字段的数据类型。
indexType
fieldName 为 id,应 indexType 为 primaryKey。
其他为 Collection 配置的可以设置 Filter 表达式的字段,索引类型固定为 filter
embedding
-
status
说明该 Collection 是否配置 Embedding 模型。
enabled:已配置。
disabled:未配置。
field
显示 Embedding 模型输入文本的字段名。
model
Embedding 模型的名称。
vectorField
显示 Embedding 模型向量字段名。
alias
-
-
集合别名。
indexStatus
-
status
标识当前 Collection 是否在重建索引。
ready:表示当前 Collection 已准备就绪,可正常使用。
training:表示当前 Collection 正在进行数据训练,即训练模型以生成向量数据。
building:表示当前 Collection 正在重建索引,即将生成的向量数据存储到新的索引中。
failed:重建索引失败,可能会影响集合读写操作。
startTime
重建索引开始的时间。