pgvector in production
Vectorizing documents inside Postgres so any workflow can search by meaning.
Our workflows move a lot of documents around. As AI steps arrived in those workflows, they needed a way to find the right document by meaning, not by file name or keyword. I built the Document Store to do that, using PostgreSQL with the pgvector extension. These are the lessons that stuck with me.
What the Document Store does
Documents that pass through the platform are vectorized: each one is turned into embeddings that capture what it is about. Those vectors are stored in PostgreSQL with pgvector, next to the rest of the platform's data. Any workflow run can then search by meaning and pass the retrieved text to its AI steps, which is the retrieval half of RAG.
Why Postgres instead of a separate vector database
A dedicated vector database is the default answer, so it's worth explaining why we didn't start there.
- We already ran Postgres. The platform's data already lives in PostgreSQL. Adding an extension is a much smaller change than adding a new system to deploy, secure, back up and monitor on AKS.
- Vectors sit next to the data they describe. A search can be combined with ordinary filters on the same tables, such as which workflow a document belongs to, in one query.
- One transaction story. When a document and its vectors are written together, they succeed or fail together.
Lessons
Retrieval quality starts before the query. How documents are split and what text goes into each embedding decides what a search can find. Most improvements came from what we stored, not from how we searched.
Treat embeddings as derived data. Vectors can always be rebuilt from the source documents, so the documents remain the source of truth and the vectors are an index on top of them.
Search belongs inside the workflow, not beside it. Because the Document Store is part of the platform, a semantic search is just another step on the canvas. People build retrieval into a flow the same way they add a database connector.
Observe it like everything else. Retrieval steps show up in the Context Graph with what they returned, so when an AI step gives a weak answer you can see whether the problem was the retrieval or the model.
What it unlocked
pgvector gave the platform semantic search and AI-ready retrieval without a new piece of infrastructure. It also changed how I think about AI features. The hard part is rarely the model call; it is getting the right context to the model, and a database you already trust is a very good place to keep that context.