milvus-logo
LFAI
< Docs
  • Python

delete()

This method deletes entities from a specified partition.

Invocation

delete(expr, timeout=None, **kwargs)

Parameters

ParameterDescriptionTypeRequired
exprBoolean expression that specifies the primary keys of the entities to delete.StringTrue
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

A MutationResult object.

Properties

PropertyDescriptionType
delete_countNumber of the entities to delete.Integer

Raises

  • RpcError: error if gRPC encounter an error.
  • ParamError: error if the parameters are invalid.
  • BaseException: error if the return result from server is not ok.

Example

import random
data = [
  [i for i in range(2000)],
  [i for i in range(10000, 12000)],
  [[random.random() for _ in range(2)] for _ in range(2000)],
]
from pymilvus import Partition
partition = Partition("book", "novel", "")
partition.insert(data)
expr = "book_id in [0,1]"
partition.delete(expr)
Feedback

Was this page helpful?