What Is a Vector Database?
What a vector database stores, how it finds the closest matches, and when to use one, explained simply for your AI interview.
In short
A vector database stores embeddings, which are lists of numbers that stand for the meaning of text, images or audio. It quickly finds the stored items closest in meaning to a question, so it can be the search step behind a retrieval-augmented generation (RAG) app, where the model answers from text it is given.
12 min readBeginnerVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
A vector database stores embeddings. An embedding is a list of numbers that stands for the meaning of a piece of text. When someone asks a question, the database finds the stored chunks closest in meaning, even when the words differ. It uses an index so it doesn't check every chunk, which means a small loss of accuracy for a big gain in speed. In a retrieval-augmented generation (RAG) app, it supplies the passages the model reads before it answers.
Start with what gets stored. An embedding model reads a passage and turns it into a long list of numbers, so passages with similar meaning end up with similar lists. A vector database keeps those lists with the original text and labels, such as the policy number and the date. Its main job is to answer one question quickly: which stored lists sit closest to this new one?
A normal keyword search finds the same words, so it can't see that a burst pipe and a water leak mean nearly the same thing. A vector database measures closeness with a distance measure such as cosine similarity (a score for how alike the direction of two lists is). It also keeps an index, so it doesn't measure every stored item for every question. The index trades a small amount of accuracy for speed, and that trade is what you tune.
Here is a real case. A mid-size insurer wants its claims assistant to answer from 400,000 policy wordings and claim notes. The database holds the chunks, the model reads the closest few, and filters keep policy B's wording away from policy A's customers. Storing the vectors is quick to set up. Choosing filters and chunk size, then testing on real questions, takes most of the project.
On its own, a vector database doesn't make an answer correct. Chunks, filters and a test set of real questions decide most of the quality.
What is a vector database, in plain words?
A vector database is a database built to store embeddings and find the closest ones quickly. An embedding is a list of numbers that stands for what a piece of text, an image or a sound means. The database keeps those lists next to the original text and labels, such as a policy number or a date.
Picture a senior claims handler who files every policy clause by what it means. When a new claim about a burst pipe arrives, she pulls the three clauses closest to it, even if none of them uses the word burst. A vector database does this filing for an AI assistant, across far more documents than one person could read.
For an AI app, that lets the model find the right paragraphs before it writes an answer. Writing the answer is the model's job. Finding the paragraphs is the database's job.
Google Cloud's definition is broad: any database that can store, index and query these embeddings. So a vector database can be a product of its own, or vector support added to a database you already run.
Key words
- Embedding
- A list of numbers that stands for the meaning of text, an image or a sound.
- Vector
- The same thing as an embedding here: a list of numbers, seen as a point in space.
- Chunk
- A short piece of a document, such as one clause or a few paragraphs, with its own embedding.
- Index
- A structure that lets the database find close vectors without checking every one.
- Metadata filter
- A rule on labels, such as policy-B or a 2026 date, that limits which chunks can be returned.
How does a vector database find the right text?
The search runs in four steps. The question is turned into numbers by the same embedding model that filed the text. The database applies any filters and measures how close each vector is to the question. Some products filter first and some search first, as explained further down. Only the top few chunks go to the model.
Say an adjuster types "Is a burst pipe covered?" into the claims assistant. The words don't match the clause exactly, but their numbers sit close to the clause about water damage from a burst pipe.
How a question finds its text
Claims question
Is a burst pipe covered?
Embedding model
turns text into numbers
Vector database
Metadata filter
only policy-B chunks stay
Closeness search
ranks the chunks that are left
Best few chunks
the text the model reads from the store
Answer with sources
built from those chunks
- 1The question is turned into a list of numbers.
- 2Those numbers go into the database.
- 3Filters drop chunks from the wrong policy or date.
- 4The closest few chunks are passed on.
- 5The model writes its answer from those chunks.
How close means is set by a distance measure. Google lists dot product, cosine similarity and Euclidean distance. Cosine similarity compares the direction of two lists and ignores their length.
“A vector database is any database that allows you to store, index, and query vector embeddings, or numerical representations of unstructured data, such as text, images, or audio.”
Google Cloud
“When you add a file to a vector store it will be automatically chunked, embedded, and indexed.”
OpenAI
Where the filter runs depends on the product. Microsoft notes that the search engine can process the filter before or after executing the vector query, so check which order your product uses.
Here is the idea in plain Python, with small made-up vectors, three numbers each, so you can follow them by hand. Two policies are stored, and the search can be limited to one of them.
# A tiny vector store for a claims team. The numbers are made up, like an embedding model's output.
import math
CHUNKS = [
("Burst pipe damage is covered up to $10,000.", "policy-A", [0.9, 0.1, 0.0]),
("Flood damage needs a separate rider.", "policy-A", [0.1, 0.9, 0.0]),
("Claims must be filed within 60 days.", "policy-B", [0.0, 0.2, 0.9]),
("Water leaks from storms are covered.", "policy-B", [0.7, 0.3, 0.1]),
]
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
norm = math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b))
return dot / norm
def search(query, k, policy=None):
# Filter by label first, then rank what is left by closeness in meaning.
rows = [c for c in CHUNKS if policy in (None, c[1])]
scored = sorted(((cosine(query, c[2]), c[0]) for c in rows), reverse=True)
return [(round(score, 3), text) for score, text in scored[:k]]
question = [0.85, 0.15, 0.05] # "Is a burst pipe covered?" as numbers
for row in search(question, k=2):
print(row)
print(search(question, k=2, policy="policy-B"))Output
(0.996, 'Burst pipe damage is covered up to $10,000.') (0.971, 'Water leaks from storms are covered.') [(0.971, 'Water leaks from storms are covered.'), (0.094, 'Claims must be filed within 60 days.')]
Why is it fast at scale, and what does it give up?
The simple method is exact. Measure the distance from the question to every stored vector, then sort. Google says that calculating the exact distance between a query vector and every other vector can be computationally expensive. A small store can cope with it. A store of millions of chunks makes that slow to repeat for every question.
Exact search versus approximate search
Exact search
Measure every chunk
the same work for each question
True closest few
exact, but costly as it grows
Approximate search
Open nearby clusters
far groups are skipped
Close enough, much faster
may miss a few true matches
- 1Each stored chunk is measured against the question, one by one.
- 2In a cluster index, only the nearby groups are opened.
Vector databases use approximate nearest-neighbour methods, which find close matches without checking every stored vector. Google describes this as trading a small amount of accuracy for speed, and calls that an acceptable compromise for most semantic search.
Many vector indexes group nearby vectors into clusters, so a query can open only the clusters near it. Google also lists graph and tree indexes, which work differently.
Worked example. A legal team holds 40,000 contracts and asks whether a clause limits liability. Exact search gives the true top ten. An approximate index may return nine of them and miss the clause that matters most. So the team tests recall (the share of true matches the search actually returns) on 200 questions with known answers, and sets the index to a recall target its lawyers can defend.
Do you always need a separate vector database?
No. Vector search can live in a dedicated product or in a database you already run. The choice depends on your data size, your team and how much of the work is search.
- Dedicated
A vector product
Built around vector search, with its own indexes and filters. A good fit when search is the main job.
- Inside your database
Vector support you already have
AlloyDB for PostgreSQL has built-in vector support through pgvector. It keeps PostgreSQL compatibility, but check speed and filters on your own data.
Google expects the second option to spread. Its page says most databases will add vector support. Whether you need a separate one is a design choice to test on your data.
How would you set up search over 400,000 claim documents?
Work through the pipeline, and name the choice at each step.
- 1
Split the documents
Cut each wording into chunks of a few paragraphs, and keep the policy number and date as labels.
- 2
Embed and store
Run every chunk through one embedding model and store the vectors with their labels. Questions must use the same model, or the distances mean nothing.
- 3
Filter and search
For a policy-B question, filter on policy B. Check whether your product applies the filter before or after the search.
- 4
Test recall
Keep 200 real questions with known right passages. Count how often the right chunk lands in the top five.
- 5
Tune and watch the cost
If recall is too low, change the index settings and measure how much slower search gets.
Tip
Say the numbers you measured, such as recall on 200 real questions. "It works" is the weak answer.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: a database that stores embeddings and finds the closest ones quickly.
- What an embedding is, and that questions and chunks must use the same model.
- Exact versus approximate search, and the accuracy-speed trade-off.
- Metadata filters, and that products apply them before or after the search.
- When vector support in an existing database is enough, and when a dedicated product fits.
- Testing: real questions with known right answers, and a recall number.
Common traps
Trap"It is a database that stores the documents, so the AI can read them."
BetterIt stores the vectors that point at the text. The model reads only the chunks you send it, so the chunking and filters matter.
Trap"Its search is exact, so it always finds the best answer."
BetterApproximate search trades a little accuracy for speed. Name that trade-off, and say how you measured recall.
Trap"Buy the biggest vector database and the answers are right."
BetterChunks, filters and a test set of real questions usually decide quality first.
Can you spot the bug, and pick the trade-off?
Spot the bug
Claims staff report that policy A wording is quoted to policy B customers. Which line causes it?
Quick check
A claims team needs to find similar clauses across 400,000 wordings quickly. What do they accept with an approximate index?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Building a search over your own documents?
Venkat designs and builds AI products and agents, including the interface and the system behind it. Book a short call and say what you need.