Delete a partition
Delete a partition from a DashVector collection using the Python SDK.
Warning
Deleting a partition is irreversible. All data in the partition is permanently deleted.
Prerequisites
Before you begin, make sure that you have:
A DashVector cluster. For more information, see Create a cluster
An API key. For more information, see Manage API keys
The latest version of the DashVector SDK. For more information, see Install DashVector SDK
API signature
Collection.delete_partition(name: str) -> DashVectorResponseRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | str | Yes | Name of the partition to delete. |
Response parameters
The method returns a DashVectorResponse object with the following fields:
| Parameter | Type | Description | Example |
|---|---|---|---|
code | int | Status code. For more information, see Status codes. | 0 |
message | str | Response message. | success |
request_id | str | Unique request ID. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
Example
Replace the following placeholders with your actual values:
| Placeholder | Description |
|---|---|
YOUR_API_KEY | API key for your DashVector cluster |
YOUR_CLUSTER_ENDPOINT | Endpoint of your DashVector cluster |
YOUR_COLLECTION_NAME | Name of the target collection |
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"
resp = collection.delete_partition('shoes')
# Check the result
if resp:
print('delete_partition success')
else:
print(f'delete_partition failed: {resp.message}')