Vector search (by meaning)
Words the toy model understood: puppy, barking
- 1.00Our cat sleeps on the keyboard all day. (Pets)
- 1.00Best food for an older dog with sensitive teeth (Pets)
- 0.99What vaccines does a new dog need? (Pets)
A vector database stores data as embeddings, lists of numbers that capture meaning, and finds the items closest in meaning to a query instead of exact matches. It is how AI apps search documents, recommend products and give language models the right context.
Each dot is one of 36 short sentences, placed by its meaning. Type a question or pick a preset: the vector search finds the closest dots by cosine similarity, while the keyword search beside it only matches exact words.
Words the toy model understood: puppy, barking
No sentence shares an exact word with your search, so keyword search finds nothing, even though the vector search found close matches.
How this demo is simplified: real embeddings come from a model and have hundreds or thousands of dimensions. Here every sentence is hand-placed in two dimensions so you can see it, and nothing you type leaves your browser.
An embedding is a list of numbers an AI model gives a piece of text, an image or a sound. The model is trained so that similar meanings get similar numbers. Picture every sentence as a point on a map: “my puppy keeps barking” lands next to “how often should I walk my dog?”, far from anything about money. Real maps have hundreds or thousands of directions instead of two, but the idea is the same.
Closeness is usually measured with cosine similarity: the angle between two vectors. A score near 1 means the same direction (very similar meaning), near 0 means unrelated. The search returns the top k closest items.
Split documents into short passages, such as a paragraph or a few hundred words, so each chunk is about one idea.
Send each chunk to an embedding model, which returns a vector of numbers that captures its meaning.
Store the vectors in an index such as HNSW, a layered graph of shortcuts that finds near neighbours without comparing against every vector.
Embed the question with the same model and ask the index for the top k most similar vectors, usually by cosine similarity.
Narrow results with metadata such as user, date or language, optionally rerank them with a stronger model, and return the original text.
HNSW in plain words: instead of comparing the question with every vector, the index hops through a few long-range links to the right neighbourhood, then through short links to the closest points. It is approximate, so it can miss a near neighbour occasionally, but it is thousands of times faster on large collections.
| Relational database | Vector database | |
|---|---|---|
| Finds rows by | Exact values: IDs, names, numbers, date ranges | Similarity of meaning between vectors |
| Example query | Orders where customer_id = 42 | Help articles most like "my card was charged twice" |
| Answer | Every row that matches, or none | The top k closest items, each with a score |
| Index | B-tree, hash | HNSW, IVF and other approximate nearest-neighbour indexes |
| Best at | Transactions, reports, joins | Semantic search, recommendations, RAG, deduplication |
New to databases? Start with What Is a Database?
Answer three questions for a starting point. Many small projects do fine with the database they already have.
Answer all three to see a recommendation.
Well-known options as of November 2026. Licences and hosting change, so check each project before you commit.
| Name | What it is | Open source | Hosting | Typical use |
|---|---|---|---|---|
| pgvector | Postgres extension | Yes (PostgreSQL License) | Self-host or most managed Postgres (Supabase, Neon, RDS, Cloud SQL) | Apps already on Postgres that want vectors beside their rows |
| Pinecone | Managed vector database | No | Managed cloud only (serverless) | Teams that want zero operations at any scale |
| Weaviate | Vector database | Yes (BSD-3) | Self-host or Weaviate Cloud | Hybrid keyword + vector search with built-in embedding modules |
| Qdrant | Vector database (Rust) | Yes (Apache 2.0) | Self-host or Qdrant Cloud | Fast search with rich metadata filters |
| Milvus | Distributed vector database | Yes (Apache 2.0) | Self-host or Zilliz Cloud | Very large collections, into the billions |
| Chroma | Embedded vector database | Yes (Apache 2.0) | In your Python or JS app, a server, or Chroma Cloud | Prototypes, notebooks and local RAG |
| LanceDB | Embedded, file-based | Yes (Apache 2.0) | In your app over local or object storage, or LanceDB Cloud | Multimodal data and serverless setups |
| Redis | In-memory store with vector search | Yes (AGPLv3 option since Redis 8) | Self-host or Redis Cloud | Low-latency lookups and semantic caching |
| Elasticsearch | Search engine with dense vectors | Yes (AGPLv3 option since 2024) | Self-host or Elastic Cloud | Adding vector search to an existing keyword search stack |
A vector database stores items as lists of numbers, called embeddings, that capture their meaning, and finds the items closest in meaning to a query. It answers "what is most like this?" instead of "what exactly matches this?"
An embedding is a list of numbers, often 384 to 3,072 of them, that an AI model produces for a piece of text, an image or audio. Things with similar meaning get similar numbers, so "puppy" ends up close to "dog" even though the words share no letters.
A relational database such as Postgres finds rows by exact values, like an ID or a date range. A vector database finds items by similarity of meaning, using approximate nearest-neighbour search. Extensions such as pgvector let one database do both.
No. Tokens are the small pieces of text, often parts of words, that a language model reads and writes. An embedding is one vector that represents the meaning of a whole word, sentence or document. Embedding models read tokens and output embeddings.
In retrieval-augmented generation, documents are split into chunks, embedded and stored in a vector database. Each question is embedded too, the closest chunks are retrieved, and they are added to the prompt so the AI answers from your documents.
It can cost nothing: pgvector, Qdrant, Weaviate, Milvus and Chroma are open source, and several managed services have free tiers. Costs grow with the number of vectors, their dimensions and query volume, so a few hundred thousand chunks usually fit on one small server.
See how retrieval fits into a full AI answer in What Is RAG? This page calls no AI or embedding service and stores nothing.
Building agents that remember and search your docs? Explore Tornic to turn your Claude Code, Codex or Cursor subscription into repeatable, reviewable workflows.