Delete documents

更新时间:
复制 MD 格式

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}/docs

Request parameters

Path parameters

ParameterTypeRequiredDescription
EndpointstrYesThe cluster endpoint. You can find this on the cluster details page in the console.
CollectionNamestrYesThe collection name.

Header parameters

ParameterTypeRequiredDescription
dashvector-auth-tokenstrYesThe API key.
Content-TypestrYesSet to application/json.

Body parameters

ParameterTypeRequiredDescription
idsarrayYesThe IDs of the documents to delete. Must be empty when delete_all is true.
partitionstrNoThe partition name.
delete_allboolNoDelete all documents in the specified partition. When true, ids must be empty.

Response parameters

ParameterTypeDescriptionExample
codeintStatus code. 0 indicates success. For more information, see Status codes.0
messagestrThe response message.success
request_idstrA 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.

{
    Usage: {
        write_units: 1
    }
}

Examples

Replace the following placeholders with your actual values:

PlaceholderDescriptionExample
<your-api-key>Your API keyLTAI5tXxx
<your-cluster-endpoint>Your cluster endpointvrs-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/docs

Sample 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