diff --git a/api/core/rag/datasource/vdb/field.py b/api/core/rag/datasource/vdb/field.py index 6a594a83ca..dc400dafbb 100644 --- a/api/core/rag/datasource/vdb/field.py +++ b/api/core/rag/datasource/vdb/field.py @@ -7,4 +7,4 @@ class Field(Enum): GROUP_KEY = "group_id" VECTOR = "vector" TEXT_KEY = "text" - PRIMARY_KEY = " id" + PRIMARY_KEY = "id" diff --git a/api/core/rag/datasource/vdb/milvus/milvus_vector.py b/api/core/rag/datasource/vdb/milvus/milvus_vector.py index bb12ef1b56..0fc8ed5a26 100644 --- a/api/core/rag/datasource/vdb/milvus/milvus_vector.py +++ b/api/core/rag/datasource/vdb/milvus/milvus_vector.py @@ -124,7 +124,12 @@ class MilvusVector(BaseVector): def delete_by_ids(self, doc_ids: list[str]) -> None: - self._client.delete(collection_name=self._collection_name, pks=doc_ids) + result = self._client.query(collection_name=self._collection_name, + filter=f'metadata["doc_id"] in {doc_ids}', + output_fields=["id"]) + if result: + ids = [item["id"] for item in result] + self._client.delete(collection_name=self._collection_name, pks=ids) def delete(self) -> None: alias = uuid4().hex