Vector search is having a moment. Every AI application seems to need it. But what is it really, and do you actually need it?
What Is Vector Search?
At its core, vector search is about finding similar things.
Instead of searching for exact keyword matches, you convert data (text, images, audio) into vectors—lists of numbers that represent meaning. Then you find vectors that are close to each other in space.
Example: The vectors for “cat”, “kitten”, and “feline” are close together in vector space because they mean similar things.
Embeddings: How Data Becomes Numbers
An embedding is a representation of data as a vector. Modern embeddings come from machine learning models trained on massive datasets.
Popular embedding models:
- OpenAI’s text-embedding-3: State-of-the-art for text, easy to use
- Google’s PaLM embeddings: Great for multilingual content
- Hugging Face embeddings: Open-source, self-hosted options
- Cohere: Purpose-built for semantic search
Similarity Metrics: How Close Is Close?
Once you have vectors, how do you measure similarity?
- Cosine similarity: Measures angle between vectors (most common, 0-1 scale)
- Euclidean distance: Straight-line distance in vector space
- Dot product: Algebraic similarity
For most use cases, cosine similarity is your friend.
Vector Databases: Do You Need One?
Here’s the hard truth: you probably don’t need a dedicated vector database yet.
Use PostgreSQL with pgvector if:
- You already use Postgres
- You have fewer than 1M vectors
- Performance is acceptable
Use Pinecone/Weaviate/Milvus if:
- You have millions of vectors
- Sub-millisecond latency is required
- You need sophisticated filtering alongside similarity search
Real-World Use Cases
- Semantic search: Find documents similar to a query, not just keyword matches
- Recommendation systems: Find products/content similar to what users liked
- Anomaly detection: Find vectors far from the normal distribution
- Image search: Find visually similar images
- Question answering: Find relevant documents to answer user questions
Vector search is powerful, but it’s not magic. It’s a tool for finding similarities. Use it when that’s actually what you need.