milvus-logo
Star
0
Forks
0
快速开始

Delete Entities

This topic describes how to delete entities in Milvus.

Milvus supports deleting entities by primary key filtered with boolean expression.

  • This feature is still under active development, and will be optimized with the release of Milvus 2.0.0-GA.
  • Deleted entities can still be retrieved immediately after the deletion if the consistency level is set lower than Strong.
  • Entities deleted beyond the pre-specified span of time for Time Travel cannot be retrieved again.
  • Frequent deletion operations will impact the system performance.

Prepare boolean expression

Prepare the boolean expression that filters the entities to delete. See Boolean Expression Rules for more information.

The following example filters data with primary key values of 0 and 1.

expr = "book_id in [0,1]"
const expr = "book_id in [0,1]";
delete entities -c book
The expression to specify entities to be deleted: pk in [0,1]
Option Description
-c The name of the collection.
-p (Optional) The name of the partition that the entities belong to.

Delete entities

Delete the entities with the boolean expression you created. Milvus returns the ID list of the deleted entities.

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.delete(expr)
await milvusClient.dataManager.deleteEntities({
  collection_name: "book",
  expr: expr,
});
You are trying to delete the entities of collection. This action cannot be undone!
Do you want to continue? [y/N]: y
Parameter Description
expr Boolean expression that specifies the entities to delete.
partition_name (optional) Name of the partition to delete entities from.
Parameter Description
collection_name Name of the collection to delete entities from.
expr Boolean expression that specifies the entities to delete.
partition_name (optional) Name of the partition to delete entities from.

What's next

该页面是否对你有帮助?
本页目录