All Products
Search
Document Center

DashVector:Delete a partition

Last Updated:Apr 11, 2024

This topic describes how to delete a partition from a collection by using the SDK for Python.

Important

After a partition is deleted, all data in it is deleted and cannot be restored. Proceed with caution.

Prerequisites

API definition

Collection.delete_partition(name: str) -> DashVectorResponse

Example

Note

You need to replace YOUR_API_KEY with your API key, YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster, and YOUR_COLLECTION_NAME with the name of your collection in the sample code for the code to run properly.

import dashvector

client = dashvector.Client(
    api_key='YOUR_API_KEY',
    endpoint='YOUR_CLUSTER_ENDPOINT'
)
collection = client.get(name='YOUR_COLLECTION_NAME')

# Delete the partition named shoes.
ret = collection.delete_partition('shoes')

# Check whether the delete_partition method is successfully called.
if ret:
    print('delete_partition success')

Request parameters

Parameter

Type

Default value

Description

name

str

-

The name of the partition to be deleted.

Response parameters

Note

A DashVectorResponse object is returned, which contains the operation result, as described in the following table.

Parameter

Type

Description

Example

code

int

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

0

message

str

The returned message.

success

request_id

str

The unique ID of the request.

19215409-ea66-4db9-8764-26ce2eb5bb99