Delete one or more documents from a DashVector collection by ID, or delete all documents in a partition.
Note
If a specified document ID does not exist in the collection, the request still succeeds. Non-existent IDs are silently ignored.
Before you begin
Before you begin, ensure that you have:
Request syntax
DELETE https://{Endpoint}/v1/collections/{CollectionName}/docsRequest parameters
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Endpoint | str | Yes | The cluster endpoint. You can find this on the cluster details page in the console. |
| CollectionName | str | Yes | The collection name. |
Header parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| dashvector-auth-token | str | Yes | The API key. |
| Content-Type | str | Yes | Set to application/json. |
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| ids | array | Yes | The IDs of the documents to delete. Must be empty when delete_all is true. |
| partition | str | No | The partition name. |
| delete_all | bool | No | Delete all documents in the specified partition. When true, ids must be empty. |
Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| code | int | Status code. 0 indicates success. For more information, see Status codes. | 0 |
| message | str | The response message. | success |
| request_id | str | A unique request identifier. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
usage | Map | For delete requests on collections in Serverless (pay-as-you-go) instances, this parameter is returned on success. It indicates the number of write request units consumed. | |
Examples
Replace the following placeholders with your actual values:
| Placeholder | Description | Example |
|---|---|---|
<your-api-key> | Your API key | LTAI5tXxx |
<your-cluster-endpoint> | Your cluster endpoint | vrs-xxx.dashvector.cn-hangzhou.aliyuncs.com |
Note
The examples use a collection named quickstart. To create this collection, see the "Example" section in Create a collection.
Delete documents by ID
curl -X DELETE \
-H 'dashvector-auth-token: <your-api-key>' \
-H 'Content-Type: application/json' \
-d '{"ids": ["1", "2"]}' \
https://<your-cluster-endpoint>/v1/collections/quickstart/docsSample response:
{
"request_id": "19215409-ea66-4db9-8764-26ce2eb5bb99",
"code": 0,
"message": ""
}Delete all documents in a partition
Set delete_all to true and specify the partition name:
curl -X DELETE \
-H 'dashvector-auth-token: <your-api-key>' \
-H 'Content-Type: application/json' \
-d '{"delete_all": true, "partition": "my_partition"}' \
https://<your-cluster-endpoint>/v1/collections/quickstart/docs该文章对您有帮助吗?