Skip to main content

Named Vectors

vectlite supports multiple vector spaces per record. For example, you can store separate embeddings for a document's title and body, then search across both.

Inserting Named Vectors

Python

db.upsert(
"doc1",
primary_embedding, # default vector
{"title": "Auth Setup", "text": "How to configure SSO..."},
vectors={"title": title_embedding, "body": body_embedding},
)

Node.js

db.upsert('doc1', primaryEmbedding,
{ title: 'Auth Setup', text: 'How to configure SSO...' },
{ vectors: { title: titleEmbedding, body: bodyEmbedding } }
)

Searching a Specific Vector Space

Python

results = db.search(title_query_embedding, k=10, vector_name="title")

Node.js

const results = db.search(titleQueryEmbedding, { k: 10, vectorName: 'title' })

Search across multiple vector spaces in a single call with custom weights:

Python

results = db.search(
k=10,
query_vectors={
"title": title_query_embedding,
"body": body_query_embedding,
},
vector_weights={"title": 1.5, "body": 1.0},
)

Node.js

const results = db.search(null, {
k: 10,
queryVectors: {
title: titleQueryEmbedding,
body: bodyQueryEmbedding,
},
vectorWeights: { title: 1.5, body: 1.0 },
})