< Docs
  • Java


A MilvusClient interface. This method deletes entity(s) based on the primary key filtered by boolean expression.

R<MutationResult> delete(DeleteParam requestParam);


Use the DeleteParam.Builder to construct a DeleteParam object.

import io.milvus.param.DeleteParam;
DeleteParam.Builder builder = DeleteParam.newBuilder();

Methods of DeleteParam.Builder:

Method Description Parameters
withCollectionName(String collectionName) Sets the collection name. Collection name cannot be empty or null. collectionName: The name of the collection to delete the entity or entities from.
withPartitionName(String partitionName) Sets the target partition name (Optional). partitionName: The name of the partition to delete the entity or entities from.
withExpr(String expr) Sets the expression filtering to pick out the entities to be deleted. expr: The expression used for filtering.
build() Constructs a DeleteParam object. N/A

The can throw the following exceptions:

  • ParamException: error if the parameter is invalid.


This method catches all the exceptions and returns an R<MutationResult> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and the error message of the exception.

  • If the API succeeds, it returns a valid MutationResult held by the R template. You can use MutationResultWrapper to get the returned information. See the corresponding section in insert() for more information about MutationResultWrapper.


import io.milvus.param.*;
import io.milvus.grpc.MutationResult;

DeleteParam param = DeleteParam.newBuilder()
        .withExpr("id in [100, 200, 300]")
R<MutationResult> response = milvusClient.delete(param);
if (response.getStatus() != R.Status.Success.getCode()) {