Vector Databases Explained Simply: A Visual Beginner’s Guide
Find the useful matches.
Raju’s tea business now has recipes, menu descriptions, supplier notes, and customer help articles. In Lesson 9, we learned to represent text using embeddings. But where do those vectors live, and how do we search a growing collection? Today, Raju builds a searchable archive—and we learn what a vector database actually does.
01. What is a vector database?
A vector database stores and manages vector representations and supports searching for similar vectors. Records usually also have an identifier and associated data or metadata. Some systems are built primarily for vector search; others add vector capabilities to an existing database.
Store
Keep vectors and associated records
Search
Find nearby vectors under a metric
Manage
Insert, update, delete, and filter
02. What goes into a record?
Raju stores one record for each menu entry. Its ID identifies the entry, its embedding supports similarity search, and its metadata describes facts such as price and availability. The original text can be stored alongside the vector or in another system referenced by the ID.
ID
tea-101
Vector
Embedding of the description
Metadata
price: 20; available: true
Source
Ginger chai description
03. Who creates the embeddings?
An embedding model converts the source text into vectors. The database stores and searches those vectors. Some products offer integrated embedding services, but these remain separate responsibilities. Query vectors and stored vectors must use a compatible embedding space and configuration.
Embedding model
Text → numerical vector
Database
Store and compare vectors
Application
Apply rules and present results
04. Ingestion: prepare the archive
Choose coherent source units, such as menu entries or document passages. Generate their embeddings, attach source IDs and metadata, and write the records to the database. Preserve the model version and preprocessing choices so future updates remain compatible.
Prepare
Clean and split source material
Embed
Encode each source unit
Write
Store vectors, IDs, and metadata
05. Search: turn a question into candidates
A customer asks for a warming ginger drink. The application embeds the query, sends it with any constraints, and retrieves ranked matches. The search response can include record IDs, scores, and associated text or metadata. The application decides what to display.
Query
A warming ginger drink
Encode + search
Compare a compatible query vector
Results
Ranked IDs, scores, and source data
06. Exact search checks the nearest matches precisely
A simple exact search computes the score for every eligible vector and selects the best ones under the chosen metric. It provides an exact nearest-neighbor baseline for that stored representation. With a small collection, this approach can be enough.
Eligible records
All records allowed by the query
Score each
Compute the chosen comparison
Select
Return the top-ranked results
07. Approximate search trades some recall for speed
An approximate nearest-neighbor, or ANN, index organizes vectors so the search can explore promising candidates instead of scoring every record. This often improves search speed for larger collections, but it may miss some exact nearest neighbors. Index settings influence the tradeoff.
Build index
Organize vector relationships
Explore
Visit promising candidates
Return
A likely-nearby shortlist
08. What are HNSW and IVF?
Two common ANN approaches are HNSW and IVF. HNSW uses a layered graph to navigate toward nearby vectors. IVF partitions the collection into groups and searches selected groups. They have different build, memory, and search tradeoffs; neither is universally best.
HNSW
Navigate a layered neighbor graph
IVF
Search selected vector groups
Evaluate
Measure on your own workload
09. Metadata filters enforce concrete conditions
Suppose the customer wants an available drink costing no more than ₹25. Semantic similarity alone cannot enforce that budget. Use structured conditions such as price ≤ 25 and available = true together with vector search. The engine may apply filters before, during, or after candidate retrieval.
Meaning
Related to warming ginger drink
Budget
price ≤ 25
Availability
available = true
- Ginger chai — ₹20 — available: eligible.
- Premium ginger latte — ₹40 — available: over budget.
- Ginger tea — ₹15 — unavailable: exclude.
Among these three fictional entries, only ginger chai meets both conditions. Vector ranking then helps choose among eligible candidates; it must not override the conditions.
10. Top-k and recall answer different questions
Top-k asks for the k highest-ranked results. To evaluate an ANN index, compare its results with exact search on the same vectors, metric, filters, and query. If the exact top five are A, B, C, D, E and ANN returns A, B, C, D, F, four of five exact neighbors were recovered.
Exact top 5
A, B, C, D, E
ANN top 5
A, B, C, D, F
Overlap
4 ÷ 5 = 80% recall
11. Keep changes and permissions synchronized
If Raju changes the text of a recipe, refresh its embedding and source record. A price-only metadata change may not need re-embedding unless the embedded text contains that price. Remove deleted content from searchable records and enforce current user permissions before exposing any result or giving it to an LLM.
Text change
Update source and embedding
Metadata change
Update the affected fields
Delete or restrict
Remove or block access to content
12. Where does this fit in RAG?
In a common Retrieval-Augmented Generation pipeline, vector search retrieves source passages, and a language model uses those passages to draft an answer. The database supplies candidates; it does not write or validate the answer. Keyword retrieval, hybrid search, and reranking may also be used.
Retrieve
Find relevant source passages
Provide context
Send permitted evidence to the model
Generate + check
Draft an answer and verify support
13. Do you need a separate database?
For a tiny experiment, an in-memory vector comparison may be sufficient. A database with vector support can suit applications that already store related records there. A dedicated vector engine may suit other workloads. For example, pgvector adds vector search to PostgreSQL, while Qdrant provides a purpose-built vector search system.
Small prototype
In-memory comparison may suffice
Existing database
Consider supported vector features
Dedicated engine
Evaluate filtering, scale, and operations
Practice: diagnose the result
A customer asks for an available drink under ₹25. Search returns a very similar drink priced at ₹40. What should you fix first?
Reveal the explanation
Check the structured price and availability conditions and the application’s handling of the results. A high similarity score cannot override the budget. Confirm the metadata is current and that the filters actually reach the search query.
Quick questions
Is a vector index the whole database?
No. An index is a search data structure. A database also manages records and operations such as updates, persistence, and access; capabilities vary by product.
Does exact search always find the right document?
It finds the nearest records under the selected vector metric. That is different from proving relevance or correctness.
Will a vector database replace SQL?
Not generally. Structured queries remain useful, and some SQL databases support vector search alongside ordinary tables and filters.
Embeddings represent content.
Indexes help search vectors.
Filters enforce conditions.
Evaluate speed and retrieval quality, keep the source current, and verify results before using them.
Next lesson: RAG from start to finish
We will connect documents, chunks, embeddings, retrieval, and generation into one complete question-answering story.
Join the conversation: What metadata would you store with a menu entry to make search more useful?
- pgvector: Exact search, ANN indexes, filtering, and operations
- Qdrant: Points and vector records
- Qdrant: Payload and metadata
All story examples and calculations were created for teaching. Check current product documentation before implementation.
Comments
Post a Comment