Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: fix qdrant delete size is too large (#35042)

wangxiaoleifc64427ae104
diff --git a/api/core/rag/datasource/vdb/tidb_on_qdrant/tidb_on_qdrant_vector.py b/api/core/rag/datasource/vdb/tidb_on_qdrant/tidb_on_qdrant_vector.py
index 605cc5a08f6..11eaf35fa51 100644
--- a/api/core/rag/datasource/vdb/tidb_on_qdrant/tidb_on_qdrant_vector.py
+++ b/api/core/rag/datasource/vdb/tidb_on_qdrant/tidb_on_qdrant_vector.py
@@ -292,26 +292,27 @@ class TidbOnQdrantVector(BaseVector):
if not ids:
return
- try:
- filter = models.Filter(
- must=[
- models.FieldCondition(
- key="metadata.doc_id",
- match=models.MatchAny(any=ids),
- ),
- ],
- )
- self._client.delete(
- collection_name=self._collection_name,
- points_selector=FilterSelector(filter=filter),
- )
- except UnexpectedResponse as e:
- # Collection does not exist, so return
- if e.status_code == 404:
- return
- # Some other error occurred, so re-raise the exception
- else:
- raise e
+ batch_size = 1000
+ for i in range(0, len(ids), batch_size):
+ batch = ids[i : i + batch_size]
+
+ try:
+ filter = models.Filter(
+ must=[
+ models.FieldCondition(
+ key="metadata.doc_id",
+ match=models.MatchAny(any=batch),
+ ),
+ ],
+ )
+ self._client.delete(
+ collection_name=self._collection_name,
+ points_selector=FilterSelector(filter=filter),
+ )
+ except UnexpectedResponse as e:
+ # Collection does not exist, so return
+ if e.status_code != 404:
+ raise e
def text_exists(self, id: str) -> bool:
all_collection_name = []