Fix behavior of delete_documents() with filters for Milvus (#1354)

* Fix behavior of delete_documents()

Delete filtered set of vectors rather than the whole collection

* Update milvus.py

* Update milvus.py
This commit is contained in:
cambiumproject 2021-08-30 08:22:53 -05:00 committed by GitHub
parent 51f0a56e5d
commit 4ca97dd5be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -403,6 +403,10 @@ class MilvusDocumentStore(SQLDocumentStore):
if status.code != Status.SUCCESS: if status.code != Status.SUCCESS:
raise RuntimeError(f'Milvus has collection check failed: {status}') raise RuntimeError(f'Milvus has collection check failed: {status}')
if ok: if ok:
if filters:
existing_docs = super().get_all_documents(filters=filters, index=index)
self._delete_vector_ids_from_milvus(documents=existing_docs, index=index)
else:
status = self.milvus_server.drop_collection(collection_name=index) status = self.milvus_server.drop_collection(collection_name=index)
if status.code != Status.SUCCESS: if status.code != Status.SUCCESS:
raise RuntimeError(f'Milvus drop collection failed: {status}') raise RuntimeError(f'Milvus drop collection failed: {status}')