All Products
Search
Document Center

DashVector:Delete documents

Last Updated:Mar 11, 2026

Delete one or more documents from a DashVector collection by primary key using the SDK for Python, or delete all documents from a partition.

Note

If the ID of a document to be deleted does not exist, the delete operation is invalid for the document.

Prerequisites

API definition

Collection.delete(
    ids: Union[str, List[str]],
    partition: Optional[str] = None,
    async_req: bool = False,
    delete_all: bool = False
) -> DashVectorResponse

Parameters

Parameter

Type

Default value

Description

ids

str or List[str]

-

Primary key or list of primary keys to delete.

partition

Optional[str]

None

Name of the partition to target.

async_req

bool

False

Enable asynchronous mode.

delete_all

bool

False

Delete all data from the partition. When set to True, ids must be left empty.

Response

DashVectorResponse contains the following fields:

Field

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

output

List[DocOpResult]

The result of the doc deletion.

Examples

Note
  1. Replace <your-api-key> with your API key and <your-cluster-endpoint> with your cluster endpoint.

  2. These examples require a collection named quickstart with documents already inserted. See Create a collection and Insert documents.

The following examples use the same client setup:

import dashvector

client = dashvector.Client(
    api_key='<your-api-key>',
    endpoint='<your-cluster-endpoint>'
)
collection = client.get(name='quickstart')

Delete a single document

Pass a single primary key as a string:

resp = collection.delete('1')
if resp:
    print('Delete succeeded')

Delete multiple documents

Pass a list of primary keys:

resp = collection.delete(['1', '2'])
if resp:
    print('Batch delete succeeded')

Delete all documents from a partition

Warning

This operation deletes all data from the partition. Do not pass any IDs when using delete_all.

Set delete_all=True to remove all documents from a partition:

resp = collection.delete(delete_all=True)
if resp:
    print('All documents deleted')

Related operations

Operation

Description

Insert documents

Insert documents into a collection.

Query documents

Query documents by vector similarity.

Create a collection

Create a new collection.