Skip to main content
You can delete documents by their _id or using a filter expression. Both methods provide the same consistency guarantees and will be reflected in query/get results according to your consistency level. To delete documents by their _id, pass a list of _ids to the delete() method:
client.collection("books").delete(
    ["book-1", "book-2", "book-3"]
)
The delete() method returns an LSN (Log Sequence Number) that you can pass to subsequent queries for read-after-write consistency.

Delete documents by filter expression

To delete documents that match a predicate, you can pass a filter expression to the delete() function.
from topk_sdk.query import field

client.collection("books").delete(field("published_year").lt(1997))
Passing a filter expression to delete() is useful for deleting documents that match a specific condition, such as all documents for a specific tenant e.g. field("_id").starts_with("tenant-123/").