Skip to main content
This page explains how to permanently remove a collection or reset it to an empty state.

Delete permanently

Deleted collections cannot be recovered. All vectors, payloads, and indexes associated with the collection are permanently removed. Back up important data before deleting.
Use the following code to permanently remove a collection and all its data.
import asyncio
from actian_vectorai import AsyncVectorAIClient

async def main():
    # Connect to VectorAI DB server
    async with AsyncVectorAIClient("localhost:50051") as client:
        # Permanently delete collection
        await client.collections.delete("my_collection")
        print("Collection deleted")

asyncio.run(main())

Recreate a collection

To reset a collection to an empty state, delete and recreate it with the same name. This is useful for testing scenarios or when you need to start fresh with a collection while maintaining the same name. The operation deletes the old collection and creates a new one in a single call.
import asyncio
from actian_vectorai import AsyncVectorAIClient, VectorParams, Distance

async def main():
    # Connect to VectorAI DB server
    async with AsyncVectorAIClient("localhost:50051") as client:
        # Removes all data and recreates with specified configuration
        await client.collections.recreate(
            "my_collection",  # Collection name
            vectors_config=VectorParams(size=128, distance=Distance.Cosine)  # Vector configuration
        )
        print("Collection recreated")

asyncio.run(main())