Delete a collection

更新时间:
复制 MD 格式

Delete a DashVector collection and all its data using the SDK for Java.

Warning

Deleting a collection permanently removes all data in it, including vectors, metadata, and indexes. This action is irreversible. Back up any data you need before deleting collections in production environments.

Prerequisites

Before you begin, make sure that you have:

API definition

// DashVectorClient
public Response<Void> delete(String name);

Sample code

Note

Replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster. The collection named quickstart must already exist. To create one, see the example in Create a collection.

import com.aliyun.dashvector.DashVectorClient;
import com.aliyun.dashvector.DashVectorCollection;
import com.aliyun.dashvector.common.DashVectorException;

public class Main {
    public static void main(String[] args) throws DashVectorException {
        // Initialize the client
        DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");

        // Delete the collection
        Response<Void> response = client.delete("quickstart");

        // Verify the result
        System.out.println("Success: " + response.isSuccess());
        System.out.println("Code: " + response.getCode());
        System.out.println("Message: " + response.getMessage());
        System.out.println("Request ID: " + response.getRequestId());
    }
}

Replace the following placeholders with your values:

PlaceholderDescriptionExample
YOUR_API_KEYYour API key for authenticationLTAI5tXxx
YOUR_CLUSTER_ENDPOINTThe endpoint URL of your DashVector clustervrs-cn-xxx.dashvector.aliyuncs.com

Request parameters

Parameter

Type

Required

Default value

Description

name

String

Yes

-

The name of the collection to delete

Response parameters

The delete method returns a Response<Void> object with the following methods:

Method

Type

Description

Example

isSuccess()

Boolean

Whether the operation succeeded

true

getCode()

int

The status code. For more information, see Status codes.

0

getMessage()

String

The response message

success

getRequestId()

String

The unique request ID

19215409-ea66-4db9-8764-26ce2eb5bb99