delete()

This operation deletes entities by their IDs or with a boolean expression.

public DeleteResp delete(DeleteReq request)

Request Syntax

delete(DeleteReq.builder()
    .databaseName(String databaseName)
    .collectionName(String collectionName)
    .partitionName(String partitionName)
    .filter(String filter)
    .ids(List<Object> ids)
    .filterTemplateValues(Map<String, Object> filterTemplateValues)
    .build()
);

BUILDER METHODS:

  • databaseName(String databaseName) -

    The name of the database. Defaults to the current database if not specified.

  • collectionName(String collectionName) -

    The name of the target collection.

  • partitionName(String partitionName) -

    The name of the target partition.

  • filter(String filter) -

    A boolean expression to filter results.

  • ids(List<Object> ids) -

    A list of primary key values to identify specific entities.

  • filterTemplateValues(Map<String, Object> filterTemplateValues) -

    A map of template variable values for parameterized filters.

RETURNS:

DeleteResp

A DeleteResp object contains the number of deleted entities.

EXCEPTIONS:

  • MilvusClientException

    This exception will be raised when any error occurs during this operation.

Example

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.vector.request.DeleteReq;
import io.milvus.v2.service.vector.response.DeleteResp;

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
        .uri("http://localhost:19530")
        .token("root:Milvus")
        .build();

MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. Delete entities with filter "id > 10"
DeleteReq deleteReq = DeleteReq.builder()
        .collectionName("test")
        .filter("id > 10")
        .build();
DeleteResp deleteResp = client.delete(deleteReq);

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?