Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting exception when trying to delete entity in Milvis vector database using pymilvus #1928

Closed
1 task done
MUsman1992 opened this issue Feb 16, 2024 · 2 comments
Closed
1 task done

Comments

@MUsman1992
Copy link

MUsman1992 commented Feb 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What is your question?

am working on the python application and I am storing data in Milvus vector database. I have written the following code to delete entity in Milvus vector database using pymilvus library.

def delete_entities(self, collection_name, entity_id):
        expr = "obj_id in [" + entity_id + "]"
        collection = Collection(collection_name)
        collection.delete(expr)

When I execute the code, I am getting this error:

RPC error: [delete], <MilvusException: (code=65535, message=failed to create expr plan, expr = obj_id in [65ce930d39989b871863b5dd])>, <Time:{'RPC start': '2024-02-16 00:53:20.651576', 'RPC error': '2024-02-16 00:53:20.653786'}>
Exception in thread Thread-9:
Traceback (most recent call last):
  File "C:\Users\usajid\AppData\Local\Programs\Python\Python39\lib\threading.py", line 980, in _bootstrap_inner
    self.run()
  File "C:\Users\usajid\AppData\Local\Programs\Python\Python39\lib\threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\usajid\Desktop\semanticsearch\src\backend\components\consumer.py", line 61, in subscribe_topic
    self.COOPERANTS.delete_entities(collection_name, payload['documentKey']['_id']['$oid'])
  File "C:\Users\usajid\Desktop\semanticsearch\src\backend\components\clients.py", line 50, in delete_entities
    collection.delete(expr)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\orm\collection.py", line 573, in delete        
    res = conn.delete(self._name, expr, partition_name, timeout=timeout, **kwargs)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\decorators.py", line 135, in handler
    raise e from e
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\decorators.py", line 131, in handler
    return func(*args, **kwargs)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\decorators.py", line 170, in handler
    return func(self, *args, **kwargs)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\decorators.py", line 110, in handler
    raise e from e
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\decorators.py", line 74, in handler
    return func(*args, **kwargs)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\client\grpc_handler.py", line 602, in delete   
    raise err from err
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\client\grpc_handler.py", line 596, in delete   
    check_status(response.status)
  File "c:\Users\usajid\Desktop\semanticsearch\.venv\lib\site-packages\pymilvus\client\utils.py", line 54, in check_status     
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=failed to create expr plan, expr = obj_id in [65ce930d39989b871863b5dd])>

Can anyone tell me how to fix this issue?

Anything else?

No response

@MUsman1992
Copy link
Author

forgot to add '' in this line

expr = "obj_id in ['" + entity_id + "']"

Now the code is working fine

@MUsman1992
Copy link
Author

Issue resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant