Skip to content
AI & MLintermediate

What is a vector database?

Updated Nov 30, 20263 min readBased on official documentation
What is a vector database?

In short

A vector database is a system that stores data as vectors, which are lists of numbers that represent items such as text, images or audio. It finds the stored items closest to a given query vector, so you can search by meaning instead of exact keywords. It suits semantic search and recommendations.

A vector database stores vectors and lets you search them quickly. A vector is simply an ordered list of numbers. Machine learning models turn text, images, audio and other content into these lists, usually called embeddings. Items with similar meaning end up with vectors that are close together in this number space.

A normal database is built for exact matches. You ask for the row where the email equals a given address, and you get that row or nothing. A vector database answers a different question: which stored items are most similar to this one? That is why it is useful for search by meaning, recommendations and finding near-duplicates.

How it works

The process has three main steps. First, you convert each item into a vector with an embedding model. Second, you store the vector together with the original item or an ID that points to it. Third, when a user asks something, you convert the query into a vector using the same model and ask the database for the nearest stored vectors.

Nearness is measured with a distance or similarity formula. Common choices include cosine similarity, which compares the direction of two vectors, and Euclidean distance, which measures the straight-line gap between them. The database returns the top matches, often with a score for each one.

For large collections, comparing the query with every stored vector is slow. Many vector databases therefore use approximate nearest neighbor search. This method gives results that are very close to the true best matches, but much faster. The trade-off is that you may occasionally miss the single best item, so you should test how accurate the results are for your data.

When to use it

A vector database fits problems where the meaning of the content matters more than the exact words. Examples include searching support articles for a question written in different words, finding similar products, or letting a chatbot pull relevant passages from your own documents before it answers.

You may not need one for small datasets. A plain list in memory, or a regular database with a simple search, can be enough when you have a few thousand items and do not need fast similarity search at scale. A vector database becomes more useful as the collection grows and as you need filters, updates and quick responses at the same time.

A simple example

Imagine a help center with three articles. You embed each article once and store the vectors. A user types 'my card was declined', and your app embeds that sentence. The database compares the query vector with the stored ones and returns the article about failed payments first, even though the article never uses the word 'declined'.

In pseudocode, the flow looks like this:

vectors = embed_model(article_texts) save(vectors, article_ids) query_vector = embed_model(user_question) matches = find_nearest(query_vector, top=3) show(matches)

The exact function names depend on the tool you choose. The pattern stays the same across tools.

Common mistakes

The most common mistake is mixing embedding models. If you embed the stored items with one model and the queries with another, the numbers do not live in the same space, and the results will be poor. Keep the model and its version fixed, and re-embed everything if you change it.

Another mistake is treating the top result as always correct. Similarity is a score, not a guarantee of relevance. Check results with real examples and measure how often the right item appears near the top. Metrics such as precision and recall, which are explained in the Google machine learning glossary, help with this kind of evaluation.

Finally, do not forget metadata. If a user needs only recent articles or items in one language, filter by those fields as well as by similarity. Pure vector search ignores these rules unless you add them.

Alternatives

You do not always need a dedicated vector database. Some regular databases can store vectors and run similarity queries, which can be simpler if you already use them. A search engine with full-text indexing may be enough when keywords match your users' needs. Keyword search is also easier to explain and debug.

The best choice depends on your data size, the kind of questions your users ask, and how much operational work your team can take on. Start with a small test on real content, compare the results with a keyword search, and then decide.

FAQ

Is a vector database the same as a normal database?

No. A normal database is designed for exact lookups and filters. A vector database is designed to find stored items that are most similar to a query vector.

Where do the vectors come from?

They come from an embedding model, which is a machine learning model that converts text, images or other content into a list of numbers. The same model must be used for stored items and for queries.

Do I need a vector database for a small project?

Often not. For a small collection, a simple in-memory list or a regular database with basic search can be enough. A dedicated system becomes more useful as the data grows.

Does vector search always return the correct answer?

No. It returns the closest matches by a similarity score, which may not always be the best answer for a user. Testing with real queries is the only reliable way to judge quality.

Sources

This page is based on the official documentation below. Read it for full detail.

Vector database — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.