Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/pyseekdb/client/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,24 @@ def _fork_database_enabled(self) -> bool:
logger.debug(f"db_type: {db_type}, version: {version}")
return db_type.lower() == "seekdb" and version >= version_120

def _refresh_enabled(self) -> bool:
db_type, version = self.detect_db_type_and_version()
version_130 = Version("1.3.0.0")
logger.debug(f"db_type: {db_type}, version: {version}")
return db_type.lower() == "seekdb" and version >= version_130

def refresh_index(self) -> None:
"""
Flush async vector index build tasks when supported.

For unsupported database versions, this method is a no-op to keep
collection-level API calls backward compatible.
"""
if not self._refresh_enabled():
return

self._execute("CALL dbms_index_manager.refresh();")

def _get_collection_id(self, collection_name: str) -> str:
collection_id_query_sql = f"SELECT COLLECTION_ID FROM `{CollectionNames.sdk_collections_table_name()}` WHERE COLLECTION_NAME = '{collection_name}'"
collection_id_query_result = self._execute(collection_id_query_sql)
Expand Down
13 changes: 13 additions & 0 deletions src/pyseekdb/client/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,19 @@ def hybrid_search(
**kwargs,
)

def refresh_index(self) -> None:
"""
Flush async vector index build tasks.

This executes ``CALL dbms_index_manager.refresh();`` and returns only
after the database completes the refresh procedure.

Note:
This method is only available for seekdb version 1.3.0.0 or higher.
In 1.2.0.0 and earlier, this method is a no-op.
"""
self._client.refresh_index()

# ==================== Collection Info ====================

def count(self) -> int:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_collection_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def test_collection_query(self, db_client):
# Insert test data
self._insert_test_data(db_client, collection_name, dimension=actual_dimension)

collection.refresh_index()

# Test 1: Basic vector similarity query
print("\n✅ Testing basic query")
# Generate query vector with correct dimension
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_collection_v1_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def test_v1_collection_query(self, db_client):
],
)

collection.refresh_index()

# Query with vector similarity
query_vector = [1.0, 2.0, 3.0]
results = collection.query(
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_offical_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def _run_official_example(collection):
ids=PRODUCT_IDS,
)

collection.refresh_index()

results = collection.query(
query_texts=["powerful computer for professional work"],
where={
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/test_sparse_vector_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def test_dense_query_still_works(self, db_client):
name = _unique_name("query_dense_with_sparse")
try:
collection, _ids, _ = self._setup_with_data(db_client, name)
collection.refresh_index()
results = collection.query(
query_embeddings=[1.0, 2.0, 3.0],
n_results=3,
Expand Down
Loading