getCollection - コレクションを取得する
getCollection()は、指定されたコレクションを取得するために使用されます。
備考
このインターフェースは、SeekdbClientを使用して接続した場合にのみ利用できます。SeekdbClientの詳細については、SeekdbClientを参照してください。
前提条件
-
seekdb-jsがインストール済みであること。seekdb-jsのインストール手順については、クイックスタートを参照してください。
-
seekdbサーバーモードがインストール済みであること。seekdbサーバーモードのインストール手順については、yum installでseekdbをデプロイするを参照してください。
-
データベースに接続されていること。接続操作の詳細については、SeekdbClientを参照してください。
-
取得したCollectionが存在すること。Collectionが存在しない場合、エラーが表示されます。
リクエストパラメータ
getCollection(options: GetCollectionOptions)
| パラメータ | 値の種類 | 必須 | 説明 | 値の例 |
|---|---|---|---|---|
name | string | 必須 | 取得するコレクションの名前を指定します。 | my_collection |
embeddingFunction | EmbeddingFunction | null | オプション | 埋め込み関数。nullを渡すと、埋め込み関数は使用されません | DefaultEmbeddingFunction() |
備考
embeddingFunction (EmbeddingFunction、オプション): このコレクション用のベクトル関数
- 指定しない場合、
createCollectionで使用されたembeddingfunctionがデフォルトで使用されます。 - nullに設定した場合、コレクションはベクトル関数を使用しません。
- ドキュメント/テキストは提供されているもののベクトルが提供されていない場合、ここで設定されたベクトル関数が、このコレクションのすべての操作(add、upsert、update、query、hybridSearch)に使用されます。
リクエスト例
import { SeekdbClient } from "seekdb";
// 1. Connect
const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: "",
database: "test",
});
// デフォルトの埋め込み関数を使用してコレクションを取得する
const collection = await client.getCollection({
name: 'my_collection'
});
// 埋め込み関数を使用しない
const collection2 = await client.getCollection({
name: 'my_collection',
embeddingFunction: null
});
レスポンスパラメータ
| パラメータ | 戻り値の型 | 必須 | 説明 | 戻り値の例 |
|---|---|---|---|---|
name | string | 必須 | クエリ対象のコレクション名を指定します。 | my_collection |
dimension | int | オプション | 384 | |
embeddingFunction | EmbeddingFunction | オプション | DefaultEmbeddingFunction { name: 'default-embed', pipe: null, modelName: 'Xenova/all-MiniLM-L6-v2', revision: undefined, dtype: undefined, cacheDir: undefined, localFilesOnly: undefined, progressCallback: undefined } | |
distance | string | オプション | cosine | |
metadata | dict | オプション | 予約フィールドです。現在データはありません。 | undefined |
戻り値の例
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
}
Collection {
name: 'my_collection',
dimension: 384,
distance: 'cosine',
embeddingFunction: undefined,
metadata: undefined
}