Vector Databases Explained Simply: A Visual Beginner’s Guide

AI BASICS TO ADVANCED · LESSON 10
Store the vectors.
Find the useful matches.
A visual introduction to vector databases and indexes.

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.

THE BASIC JOB
01
Store
Keep vectors and associated records
02
Search
Find nearby vectors under a metric
03
Manage
Insert, update, delete, and filter
The database does not automatically know whether a result is factually correct or useful to the reader.

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.

ONE MENU RECORD
01
ID
tea-101
02
Vector
Embedding of the description
03
Metadata
price: 20; available: true
04
Source
Ginger chai description
The ID and price are fictional. A vector alone does not replace the original source text.

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.

KEEP THE JOBS CLEAR
01
Embedding model
Text → numerical vector
02
Database
Store and compare vectors
03
Application
Apply rules and present results
Matching vector lengths is necessary for many comparisons, but does not make unrelated embedding models compatible.

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.

BEFORE USERS SEARCH
01
Prepare
Clean and split source material
02
Embed
Encode each source unit
03
Write
Store vectors, IDs, and metadata
Ingestion means bringing data into the searchable collection. It is not the same as training the embedding model.

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.

WHEN A QUESTION ARRIVES
01
Query
A warming ginger drink
02
Encode + search
Compare a compatible query vector
03
Results
Ranked IDs, scores, and source data
Cosine similarity, dot product, and Euclidean distance are different scoring choices. Use the metric appropriate to the embedding model.

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.

EXHAUSTIVE SEARCH
01
Eligible records
All records allowed by the query
02
Score each
Compute the chosen comparison
03
Select
Return the top-ranked results
Exact nearest neighbors are not guaranteed to be semantically correct. The embedding model can still rank an irrelevant passage highly.

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.

APPROXIMATE SEARCH
01
Build index
Organize vector relationships
02
Explore
Visit promising candidates
03
Return
A likely-nearby shortlist
ANN here means approximate nearest neighbor, not artificial neural network. Performance depends on data, filters, settings, and hardware.

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.

TWO INDEX IDEAS
01
HNSW
Navigate a layered neighbor graph
02
IVF
Search selected vector groups
03
Evaluate
Measure on your own workload
These are simplified descriptions. Actual implementations and supported options differ across systems.

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.

SIMILARITY + CONDITIONS
01
Meaning
Related to warming ginger drink
02
Budget
price ≤ 25
03
Availability
available = true
Filtering strategy can affect speed and the number of results. Test selective filters; do not assume every engine executes them in the same order.
Raju’s filtering example
  • 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.

TOY RECALL@5 EXAMPLE
01
Exact top 5
A, B, C, D, E
02
ANN top 5
A, B, C, D, F
03
Overlap
4 ÷ 5 = 80% recall
This is a hand-written example, not a benchmark. Neighbor recall is distinct from relevance judged by humans and does not measure answer truth.

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.

MAINTAIN THE SEARCH DATA
01
Text change
Update source and embedding
02
Metadata change
Update the affected fields
03
Delete or restrict
Remove or block access to content
A similarity score never grants permission. Embeddings of sensitive content also need appropriate protection.

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.

RETRIEVAL SUPPORTS GENERATION
01
Retrieve
Find relevant source passages
02
Provide context
Send permitted evidence to the model
03
Generate + check
Draft an answer and verify support
RAG does not require a dedicated vector database, and adding one does not eliminate hallucinations.

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.

CHOOSE BY REQUIREMENTS
01
Small prototype
In-memory comparison may suffice
02
Existing database
Consider supported vector features
03
Dedicated engine
Evaluate filtering, scale, and operations
Compare relevance, latency, memory, update behavior, access control, backups, and cost. These examples are not a ranking or a product recommendation.

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.

YOUR ONE-MINUTE RECAP

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?


Sources and further reading

All story examples and calculations were created for teaching. Check current product documentation before implementation.

Comments

Popular posts from this blog

Beyond Standard RAG: The Architecture of Agentic Retrieval and Self-Correction Loops

The Architecture of Vision-Language Models: How Multimodal AI Sees and Understands the World

Java Collection Framework: A Practical Guide with Examples