Skip to main content

Collections & Namespaces

vectlite offers two levels of data organization: physical collections and logical namespaces.

Collections (Store)

A Store manages a directory of independent databases, each with its own .vdb file and dimension.

Python

store = vectlite.open_store("./my_collections")

# Create a new collection
products = store.create_collection("products", dimension=384)
products.upsert("p1", embedding, {"name": "Widget", "price": 9.99})

# Open or create (idempotent)
logs = store.open_or_create_collection("logs", dimension=128)

# List collections
print(store.collections()) # ["logs", "products"]

# Drop a collection
store.drop_collection("logs")

Node.js

const store = vectlite.openStore('./my_collections')

const products = store.createCollection('products', 384)
products.upsert('p1', embedding, { name: 'Widget', price: 9.99 })

const logs = store.openOrCreateCollection('logs', 128)
console.log(store.collections()) // ["logs", "products"]

store.dropCollection('logs')

Namespaces

Namespaces provide logical isolation within a single database file. Each record belongs to a namespace (default: "").

Writing with Namespaces

db.upsert("doc1", emb1, {"title": "Guide"}, namespace="docs")
db.upsert("faq1", emb2, {"title": "FAQ"}, namespace="support")
db.upsert('doc1', emb1, { title: 'Guide' }, { namespace: 'docs' })
db.upsert('faq1', emb2, { title: 'FAQ' }, { namespace: 'support' })

Searching within a Namespace

results = db.search(query, k=5, namespace="docs")
const results = db.search(query, { k: 5, namespace: 'docs' })
results = db.search(query, k=5, all_namespaces=True)
const results = db.search(query, { k: 5, allNamespaces: true })

Listing Namespaces

print(db.namespaces())  # ["", "docs", "support"]