Reputation: 1321
The below code I have executed to delete a record from Milvus collection. There is no error but the respective record also not deleted.
Please recommend solution for this
from pymilvus import connections,Collection,db,utility,FieldSchema, CollectionSchema
def connectVectorDB(**conStrings):
try:
milvusDB = connections.connect(
#db_name=conStrings['dbName'],
host=conStrings['hostname'],
port=conStrings['port']
)
db.using_database(conStrings['dbName'])
return milvusDB
except Exception as err:
raise err
dbConnections = connectVectorDB(dbName='default',hostname="localhost",port='19530')
myCol = Collection('DocStrings')
expression = "docID == 445341931317291845"
myCol.delete(expr=expression)
myCol.flush()
Upvotes: 0
Views: 1075
Reputation: 57
A couple of questions first:
docId
defined as a primary key in the collection?Also in the example above you're using ==
which is not allowed before 2.3.2.
Milvus only supports deleting entities with clearly specified primary keys, which can be achieved merely with the term expression
in
.
I.e. One may use boolean expressions like expr = "book_id in [0,1]"
where book_id
is defined as primary key.
Since 2.3.2 it is possible to delete entities not only by primary key, but also using complex boolean expressions:
Milvus supports deleting entities by primary key or complex boolean expressions. Deleting entities by primary key is much faster and lighter than deleting them by complex boolean expressions. This is because Milvus executes queries first when deleting data by complex boolean expressions.
It worth to mention that:
Strong
.Bounded
.See: https://milvus.io/docs/delete_data.md
Upvotes: 0