Chapter 11: Embeddings and hybrid storage in PostgreSQL
Use one PostgreSQL database with VectorChord for vectors, and its BM25 extension for keywords. The table holds the text, the metadata, the embedding, and the keyword vector.
CREATE TABLE IF NOT EXISTS corpus (
id TEXT PRIMARY KEY,
service TEXT NOT NULL,
doc_type TEXT NOT NULL,
source TEXT NOT NULL,
text TEXT NOT NULL,
emb vector(1024),
bm25 bm25vector
);
BGE-M3 runs in LM Studio and produces 1024-dimension vectors. Split documents into chunks of about 1200 characters with 150 overlapping. Embed each chunk, then insert it. A startup check confirms the vector size matches the table.
bm25vector column is filled; see the Verify note below.Verify: Create the BM25 index with the statement in the VectorChord-BM25 repository. The reference article does not show it.