From 61e5b7c03bc19fb2004064e6410bd3bc16de55a4 Mon Sep 17 00:00:00 2001 From: stevenlx96 Date: Mon, 14 Jul 2025 13:51:29 +0800 Subject: [PATCH] Fix milvus truncate Fixed the indent bug --- .../storage/vector_store/milvus_store.py | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/milvus_store.py b/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/milvus_store.py index 7af7dc216..635bab557 100644 --- a/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/milvus_store.py +++ b/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/milvus_store.py @@ -727,29 +727,29 @@ class MilvusStore(VectorStoreBase): metadata_filter_expr = metadata_filters[0] return metadata_filter_expr -def truncate(self): - """检测pymilvus安装""" - try: - from pymilvus import Collection, utility - except ImportError: - raise ValueError( - "Could not import pymilvus python package. " - "Please install it with `pip install pymilvus`." - ) - """安全清空 Milvus summary collection 中所有数据,但不删除 collection 本身""" - logger.info(f"Begin truncate Milvus collection: {self.collection_name}") - # 先判断 collection 是否存在 - if utility.has_collection(self.collection_name): - collection = Collection(self.collection_name) - # Load collection 必须调用,才能执行 delete - collection.load() - # 通过pk_id删除所有数据 - collection.delete("pk_id >= 0") - # flush 确保数据删除被提交 - collection.flush() - logger.info(f"Truncate Milvus collection {self.collection_name} success") - else: - logger.warning(f"Collection {self.collection_name} not found, skip truncate.") + def truncate(self): + """检测pymilvus安装""" + try: + from pymilvus import Collection, utility + except ImportError: + raise ValueError( + "Could not import pymilvus python package. " + "Please install it with `pip install pymilvus`." + ) + """安全清空 Milvus summary collection 中所有数据,但不删除 collection 本身""" + logger.info(f"Begin truncate Milvus collection: {self.collection_name}") + # 先判断 collection 是否存在 + if utility.has_collection(self.collection_name): + collection = Collection(self.collection_name) + # Load collection 必须调用,才能执行 delete + collection.load() + # 通过pk_id删除所有数据 + collection.delete("pk_id >= 0") + # flush 确保数据删除被提交 + collection.flush() + logger.info(f"Truncate Milvus collection {self.collection_name} success") + else: + logger.warning(f"Collection {self.collection_name} not found, skip truncate.") def full_text_search(