Skip to content

LearnIndex & store

Vector database

Vector store

A database that stores embeddings next to their source records and answers "which rows are nearest to this vector?", usually through an ANN index plus metadata filters.

In DocSlurpGlossary entry

On this page

A vector database stores embeddings alongside the records they came from and answers nearest-neighbor queries: “the 10 rows whose vectors are closest to this one, where document_id is in this set”. Underneath it combines an approximate nearest neighbor index (such as HNSW or IVF), storage for the vectors and their metadata, and a query layer for filters.

A retrieval system typically stores one row per chunk: an id, the chunk vector, the document id, a page number and perhaps the text. A search embeds the question, asks the database for the nearest rows within the allowed documents, and uses the returned ids to fetch text and citations.

Options range from dedicated servers to libraries embedded in the application (LanceDB) and extensions to general databases (pgvector for PostgreSQL).

The gotchas

The nearest-neighbor math is the easy part. The hard parts are everything around it:

  • Filtering without losing recall, since an approximate index and a selective filter work against each other.
  • Freshness: new rows must become searchable before the index is rebuilt.
  • Updates and deletes, which approximate indexes handle poorly.
  • Tenant isolation: one customer’s query must never reach another’s vectors, which is safest when the data is physically separate rather than filtered.
  • Model changes: vectors from different embedding models can’t be compared, so changing models means re-embedding (see embedding versioning).

DocSlurp keeps vectors in LanceDB, in a separate database per project and embedding model, and keeps chunk text and metadata in PostgreSQL.

In DocSlurp

In DocSlurp

Vectors live in LanceDB, one database per project and embedding model; chunk text, metadata and PostgreSQL keyword search stay in PostgreSQL (its vector columns were dropped in core/server/db/migrations/0008_lancedb_object_storage_vectors.sql). Searches filter to in-scope documents before choosing neighbors (core/server/src/search/lancedb.ts).

Sources

Jump to