跳到主要内容
版本:V1.1.0

listCollections - 获取 Collections 列表

listCollections() 用于获取全部的 Collection。

信息

仅支持在使用 SeekdbClient 连接时,才能使用该接口。关于 SeekdbClient 的详细介绍,参见 SeekdbClient

前提条件

  • 您已经安装了 seekdb-js,有关安装 seekdb-js 的详细信息,参见 快速开始

  • 您已经安装了 seekdb 服务器模式,有关安装 seekdb 服务器模式的详细信息,参见 通过 yum install 部署 seekdb

  • 您已经连接到数据库。有关连接的详细操作参见 SeekdbClient

  • 您获取的 Collection 存在。如果 Collection 不存在,则会提示报错。

请求参数

listCollections()

请求示例

import { SeekdbClient } from "seekdb";

// 1. Connect
const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: "",
database: "test",
});

const collections = await client.listCollections();

返回参数

参数取值类型是否必选描述取值示例
namestring必选查询到的 Collection 的名称。my_collection
dimensionint可选384
embeddingFunctionEmbeddingFunction可选embeddingFunction: DefaultEmbeddingFunction {name: 'default-embed', pipe: null, modelName: 'Xenova/all-MiniLM-L6-v2', revision: undefined, dtype: undefined, cacheDir: undefined, localFilesOnly: undefined, progressCallback: undefined }
distancestring可选cosine
metadatadict可选预留字段,暂无数据

返回示例

[
Collection {
name: 'my_collection',
dimension: 384,
distance: 'cosine',
embeddingFunction: DefaultEmbeddingFunction {
name: 'default-embed',
pipe: null,
modelName: 'Xenova/all-MiniLM-L6-v2',
revision: undefined,
dtype: undefined,
cacheDir: undefined,
localFilesOnly: undefined,
progressCallback: undefined
},
metadata: undefined
}
]

相关操作