Start With Full-Text Search

If people search with the words your products use, Postgres full-text search is enough, and it's already there. Vector search earns its place when they describe what they want in their own words and keyword matching returns nothing.

You need semantic search over your products, and the first instinct is a separate vector database plus a job to sync data into it. Then search shows out-of-stock products, deleted items linger, and you have a second system to run, back up and secure.

pgvector puts vectors in a Postgres column next to the rows they describe, so filters on stock, price or permissions run in the same query. It has matured quickly: half-precision and binary vector types cut index sizes, and iterative index scans (0.8) fixed the problem of filtered searches returning too few results. Below is how to use it, and where its ceiling is.

If you are about to add a vector database
  • You spun up a separate vector DB just for RAG and now you're syncing two stores
  • You don't know whether to pick HNSW or IVFFlat
  • Your queries are slow and you don't know what ef_search does
  • You're storing 1536-dim float32 and your table is 50 GB