接口定义
DescribeCollection() 用于查找指定 Collection 的配置信息。
DescribeCollection(ctx context.Context, name string) (result *tcvectordb.DescribeCollectionResult, err error)
使用示例
如下示例,通过接口
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 名称。 |
出参描述
{"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}}],"SparseVectorIndex": [{"FieldName": "sparse_vector","FieldType": "sparseVector","IndexType": "inverted","MetricType": "IP",}],"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。 |
| | fieldType | 向量索引的数据类型,固定为 vector。 |
| | indexType | |
| | indexedCount | 向量索引的文档数量。 |
| | dimension | 向量维度。 |
| | metricType | 向量之间的距离度量的算法。 |
| | params | 向量索引类型对应的参数。 |
| FilterIndex | fieldName | id:默认对 id 构建主键 Filter 索引,对应 indexType 为 primaryKey。 page、bookName、tag:自定义扩展的设置为 Filter 表达式的字段名。 |
| | fieldType | Filter 字段的数据类型。 |
| | indexType | fieldName 为 id,indexType 为 primaryKey。 标识自定义字段是否可以设置 Filter 表达式,固定为 filter。 |
| SparseVectorIndex | fieldName | 稀疏向量字段名,固定为: sparse_vector。 |
| | fieldType | 稀疏向量数据类型,固定为: sparseVector。 |
| | indexType | 索引类型,固定为: inverted。 |
| | metricType | 稀疏向量间的距离度量的算法。 |
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 | 重建索引开始的时间。 |