接口定义
listcollections() 接口用于查询指定 Base 类 Database 中所有的 Collection。
public List<Collection> listCollections()
使用示例
// link databaseDatabase db = client.database("db-test");// list collectionsList<Collection> cols3 = db.listCollections();for (Collection col : cols3) {System.out.println(col.toString());}
出参描述
输出结果,如下所示。
{"database": "db-test","collection": "book-emb","replicaNum": 2,"shardNum": 3,"description": "this is an embedding collection","indexes": [{"fieldName": "bookName","fieldType": "string","indexType": "filter"},{"fieldName": "vector","fieldType": "vector","indexType": "HNSW","metricType": "COSINE","params": {"efConstruction": 200,"M": 16},"dimension": 768,"indexedCount": 0},{"fieldName": "id","fieldType": "string","indexType": "primaryKey"},{"fieldName": "author","fieldType": "string","indexType": "filter"},{"fieldName": "sparse_vector","fieldType": "sparseVector","indexType": "inverted","metricType": "IP"}],"createTime": "2023-09-26 17:30:42","embedding": {"field": "text","vectorField": "vector","model": "bge-base-zh","status": "enabled"},"indexStatus": {"status": "ready","startTime": ""},"alias": ["book-emb-alias"]}
参数 | 子参数 | 子参数 | 参数含义 |
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 | 标识自定义字段是否可以设置 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:表示首次创建索引,尚未 Rebuild 构建索引。 ready:表示当前 Collection 已准备就绪,可正常使用。 training:表示当前 Collection 正在进行数据训练,即训练模型以生成向量数据。 building:表示当前 Collection 正在重建索引,即将生成的向量数据存储到新的索引中。 failed:重建索引失败,可能会影响集合读写操作。 |
| | startTime | 重建索引开始的时间。 |