メインコンテンツまでスキップ
バージョン: V1.4.0

getCollection - コレクションを取得する

getCollection()は、指定されたコレクションを取得するために使用されます。

備考

このインターフェースは、SeekdbClient接続を使用する場合にのみ利用できます。SeekdbClientの詳細については、SeekdbClientを参照してください。

前提条件​

  • seekdb-jsがインストール済みであること。seekdb-jsのインストール手順の詳細については、クイックスタートを参照してください。

  • サーバーモードのseekdbを使用している場合は、seekdbサーバーモードがインストールされていることを確認してください。seekdbサーバーモードのインストール手順の詳細については、パッケージ管理ツールによるseekdbのデプロイを参照してください。

  • データベースに接続されていること。接続操作の詳細については、SeekdbClientを参照してください。

  • 取得するコレクションが存在すること。コレクションが存在しない場合は、エラーが表示されます。

リクエストパラメータ​

getCollection(options: GetCollectionOptions)
パラメータ値の種類必須説明値の例
namestring必須取得するコレクションの名前を指定します。my_collection
embeddingFunctionEmbeddingFunction | nullオプション埋め込み関数。nullを指定すると、埋め込み関数は使用されませんDefaultEmbeddingFunction()
備考

embeddingFunction (EmbeddingFunction、オプション): このコレクション用のベクトル関数

  • 指定しない場合、createCollection で使用した embeddingfunction をデフォルトで使用します。
  • nullに設定すると、コレクションはベクトル関数を使用しません。
  • ドキュメント/テキストは指定されているもののベクトルが指定されていない場合、ここで設定されたベクトル関数が、このコレクションのすべての操作(add, upsert, update, query, hybridSearch)に適用されます。

リクエスト例​

import { SeekdbClient } from "seekdb";

// 1. Connect
// 埋め込みモード - データベース管理 (seekdb Embedded)
// const client = new SeekdbClient({
// path: "./seekdb.db",
// database: "test",
// });

// リモートサーバーモード - データベース管理 (seekdb Server)
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
});

戻り値パラメータ​

パラメータ戻り値の型必須説明実行例
namestring必須検索するコレクション名を指定します。my_collection
dimensionintオプション384
embeddingFunctionEmbeddingFunctionオプション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オプション予約フィールド、現在データなし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
}

関連操作​