Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Data Science

Vector database: What it stores and when to use one

A vector database stores embeddings, lists of numbers that capture meaning, and finds the ones closest to a query fast. It powers semantic search and RAG.

Monthly searches · vector database
60.5k
Keyword research data
vector database
Vector database: What it stores and when to use one
Click the image to view it full size

An ordinary database answers "which rows contain the word smartphone?". A vector database answers "which items are closest in meaning to smartphone?", and can return "mobile phone" or "cell phone" without sharing a single word.

It can do that because it never stores the text as text. An AI model first turns each item (a sentence, a product description, an image) into an embedding, a fixed list of numbers, trained so that items with similar meaning end up with similar numbers. The database then has one job: take a new list of numbers and find the stored lists most like it, quickly, among millions.

How meaning becomes numbers

An embedding model reads an item and outputs a fixed-length list of numbers, often hundreds or thousands long. Think of each list as a point on a map with that many directions. The model is trained so that related items land near each other: "running shoes" sits close to "trainers" and far from "running a business".

The database never understands the text itself. It only stores the points and measures distances between them. The quality of the results depends mostly on the embedding model, not the database.

How a query runs

  1. Store. Each item is turned into an embedding and saved, usually with its ID and some metadata (category, price, date, language).
  2. Embed the query. The search text is turned into an embedding with the same model. Vectors from different models can't be compared.
  3. Measure closeness. The database compares the query with stored vectors. Common measures are cosine similarity (the angle between two vectors), dot product and Euclidean (straight-line) distance.
  4. Return the nearest. The closest items come back, ranked. Many systems filter by metadata as well, such as "similar to this, but under $100".

Comparing the query with every stored vector gives exact results, but gets slow as the collection grows. So vector databases build an index for approximate nearest neighbor (ANN) search, which checks only a small, promising part of the collection.

A widely used index is HNSW, a set of layered graphs that link each vector to its near neighbors. A search starts on a sparse top layer and walks down to denser ones; its authors showed the work grows roughly logarithmically with the collection size Malkov and Yashunin. The trade-off is that an approximate search can miss some true nearest neighbors. Settings let you choose more accuracy (recall) or more speed. The vector search article explains how recall is measured.

What vector databases are used for

  • Semantic search: site search that finds the right page when visitors use different words from your copy. See semantic search.
  • Recommendations: "similar products" or "related articles" based on meaning or appearance, not just shared tags.
  • Grouping and deduplication: clustering similar keywords, questions or support tickets.
  • Retrieval-augmented generation (RAG): an AI assistant first retrieves relevant passages from a vector index, then writes its answer from them. The 2020 paper that named the approach paired a language model with a dense vector index of Wikipedia and got more specific, more factual answers than the model alone Lewis et al.. See retrieval-augmented generation.

Do you need a separate one?

Not always. Vector databases come as dedicated systems, as hosted services, and as extensions that add vector columns and indexes to databases you may already run. A small collection, say a few thousand articles, can even be searched exactly without any special index.

Choose based on size, how often the data changes, and whether you need to combine vector search with ordinary filters and joins. Keeping vectors next to the rest of your data is simpler; a dedicated system can make sense at very large scale.

Limits to keep in mind

  • Exact lookups need exact search. Order numbers, SKUs and names are better found with ordinary queries or keyword search. Many systems combine both.
  • Similar isn't always relevant. "Cheap flights to Paris" and "expensive flights to Paris" can sit close together. Filters and re-ranking help.
  • Changing the model means re-embedding everything, because old and new vectors live on different maps.
  • Embeddings cost memory. Long vectors for millions of items take real storage and RAM, which is why some systems shorten or compress them.
Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.