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

refresh_index - 非同期ベクトルインデックスの可視性を推進する

Collectionインスタンス上の refresh_index() は、HNSW非同期ベクトルインデックスシナリオにおいて、現在のCollectionが対応するテーブル内でコミット済みの非同期書き込みが可能な限り迅速に近似ベクトル検索で可視化されることを保証します。意味的にはSQLの CALL dbms_index_manager.refresh(); に相当し、詳細は REFRESH(DBMS_INDEX_MANAGER) を参照してください。

備考

このメソッドは、SeekdbClientを使用して接続した場合にのみ、取得済みのCollectionインスタンスから呼び出すことができます。SeekdbClientの詳細については、SeekdbClientを参照してください。

説明​

  • seekdbサーバーモードと組み込みモードでは、V1.3.0以降、デフォルトで非同期ベクトルインデックスが使用されます。書き込み後に近似検索で直ちにデータを参照する必要がある場合は、add / upsert などの書き込み後に await collection.refresh_index() を呼び出すことをお勧めします。

前提条件​

リクエストパラメータ​

なし。

レスポンスパラメータ​

なし。

リクエスト例​

import { SeekdbClient } from "seekdb";

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

const name = "t1";
if (await client.hasCollection(name)) {
await client.deleteCollection(name);
}

const collection = await client.createCollection({
name,
configuration: { dimension: 3, distance: "l2" },
embeddingFunction: null,
});

await collection.add({
ids: ["16", "17", "18"],
embeddings: [
[1.0, 2.0, 3.0],
[1.0, 2.0, 3.0],
[1.0, 2.0, 3.0],
],
documents: ["seekdb 1.0", "seekdb 1.0", "seekdb 1.0"],
});

await collection.refresh_index();

const q = await collection.query({
queryEmbeddings: [[100, 100, 100]],
nResults: 5,
approximate: true,
include: ["documents", "distances"],
});

const rows = (q.ids[0] ?? []).map((id, i) => ({
id: Number(id),
document: q.documents?.[0]?.[i] ?? null,
distance: q.distances?.[0]?.[i] ?? null,
}));
console.log(rows);

await client.deleteCollection(name);

関連ドキュメント​