Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lambdadb.ai/llms.txt

Use this file to discover all available pages before exploring further.

This page shows you how to use the delete endpoint to remove documents from a collection.

Delete documents by IDs

Since LambdaDB documents can always be efficiently accessed using their ID, deleting by ID is the most efficient way to remove specific records.
from lambdadb import LambdaDB

with LambdaDB(
    project_api_key="YOUR_API_KEY",
    base_url="YOUR_BASE_URL",
    project_name="YOUR_PROJECT_NAME",
) as client:
    coll = client.collection("your_collection_name")
    coll.docs.delete(ids=["example-doc-id-1", "example-doc-id-2"])

Delete documents by query

To delete documents based on their data, pass a filter query to the delete operation. This deletes all documents matching the filter query. For example, to delete all documents with genre “documentary” and year 2019 from a collection, use the following code:
with LambdaDB(
    project_api_key="YOUR_API_KEY",
    base_url="YOUR_BASE_URL",
    project_name="YOUR_PROJECT_NAME",
) as client:
    coll = client.collection("your_collection_name")
    coll.docs.delete(query_filter={"queryString": {"query": "genre:documentary AND year:2019"}})

Delete an entire collection

To remove all documents from a collection, delete the collection and recreate it. Deletion is asynchronous: if you reuse the same collection name, wait until the name is fully released (for example by polling describe until the collection returns not found) before calling create—see Wait for deletion before recreating.