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

refresh_index - 推进异步向量索引可见性

Collection.refresh_index() 用于在 HNSW 异步向量索引场景下,确保当前 Collection 对应表中已提交的异步写入尽快在带近似的向量检索中可见,语义上对应 SQL CALL dbms_index_manager.refresh();,详见 REFRESH(DBMS_INDEX_MANAGER)。

信息

仅支持在使用 Client 连接时,通过已获取的 Collection 实例调用本方法。关于 Client 的详细介绍,参见 Client。

说明​

  • seekdb 在服务器模式与嵌入式模式下,自 V1.3.0 起默认使用异步向量索引;写入后若需立即在近似检索中看到数据,可在 add / upsert 等写入后调用 refresh_index()。

前提条件​

  • 您已经安装了 pyseekdb,有关安装说明参见 快速开始。
  • 您已经连接到数据库,参见 Client。
  • 已获取目标 Collection(例如通过 create_collection 或 get_collection)。

请求参数​

无。

返回参数​

无(方法在服务端推进可见性后返回)。

请求示例​

import pyseekdb
from pyseekdb import HNSWConfiguration, Schema, VectorIndexConfig

client = pyseekdb.Client(
host="127.0.0.1",
port=2881,
database="test",
user="root",
)

name = "t1"
schema = Schema(
vector_index=VectorIndexConfig(
hnsw=HNSWConfiguration(dimension=3, distance="l2")
)
)
collection = client.create_collection(
name=name,
Schema=schema,
embedding_function=None,
)

collection.add(
ids=["16", "17", "18"],
embeddings=[[1.0, 2.0, 3.0], [1.1, 2.1, 3.1], [1.2, 2.2, 3.3]],
documents=["seekdb 1.0", "seekdb 1.1", "seekdb 1.2"],
)

collection.refresh_index()

res = collection.query(
query_embeddings=[[100.0, 100.0, 100.0]],
n_results=5,
include=["documents"],
)
print("result ids:", res["ids"][0])

client.delete_collection(name)

相关文档​