milvus-logo
LFAI
< Docs
  • Python
    • MilvusClient

delete()

This method deletes one or more entities from a collection.

Invocation

delete(
    collection_name,
    pks,
    timeout
)

Parameters

ParameterDescriptionTypeRequired
collection_nameName of the collection from which data is deleted.StringTrue
pksPrimary keys of the entities to delete.Union[list, str, int]True
timeoutAn optional duration of time in seconds to allow for the RPC. If it is set to None, the client keeps waiting until the server responds or error occurs.FloatFalse

Return

None

Raises

None

Example

  • Delete an entity by a primary key of a string:

    from pymilvus import MilvusClient
    
    client = MilvusClient(uri, token)
    
    client.delete(
        collection_name='my-collection1',
        pks='pk-1'
    )
    
  • Delete an entity by a primary key of an integer:

    from pymilvus import MilvusClient
    
    client = MilvusClient(uri, token)
    
    client.delete(
        collection_name='my-collection2',
        pks=256
    )
    
  • Delete multiple entities by primary keys:

    from pymilvus import MilvusClient
    
    client = MilvusClient(uri, token)
    
    client.delete(
        collection_name='my-collection3',
        pks=['pk-1', 'pk-2']
    )
    
Feedback

Was this page helpful?