Vector Databases & AI Search
Vector databases store embeddings — high-dimensional numerical representations of text, images, or audio produced by machine learning models. Instead of exact keyword matching, vector search finds results that are semantically similar: searching for "heart attack" can return results about "myocardial infarction" because their embeddings are close in vector space.
The core operation is Approximate Nearest Neighbor (ANN) search. You embed the query using the same model that produced the stored embeddings, then find the K vectors in the database closest to the query vector. Pinecone, Weaviate, Qdrant, and pgvector (a Postgres extension) are the most common choices. pgvector is the simplest path if you already run Postgres — add the extension and a vector column, no new infrastructure needed.
Check your understanding
What does ANN search return?Show answerHide answer
Answer
Approximate nearest neighbors — vectors close to the query embedding in the chosen distance metric.Why must query and stored embeddings use the same model?Show answerHide answer
Answer
Different models live in different vector spaces; mixing them makes distance meaningless.When is pgvector a reasonable first step?Show answerHide answer
Answer
When you already run Postgres and want semantic search without standing up a separate vector service yet.