What is a vector database and how does vector search work?
sorchy team
5 min read
Imagine searching a library website for “Can I keep my book a little longer?” The page you need is titled “Renewing Loans.” You know what you want to do, but you may never think to search for “loan renewal.” Vector search can help you find the relevant instructions even when you and the library use different words.
We explored this problem in our article on why visitors abandon site search. To see how vector search helps, it’s worth looking at what happens to the library’s content before a visitor asks a question.
What is a vector database?
A vector database stores numerical representations of content and lets you search for records with similar representations. In a typical setup, an embedding model converts each passage of text into a sequence of numbers called a vector. The database stores that vector alongside a reference to the passage and uses it to find matches when a query comes in.
For the library, a record might contain the vector for a paragraph about renewals, the title of that section, and the URL of the borrowing policy. Details such as the title, language, or category are called metadata. They help narrow the search and take the visitor back to the passage that was found.
Some products provide the embedding model and the database as a single service. When evaluating one, check how it processes a new page, what happens when you update that page, and whether a visitor can open the original source from the results.
Traditional Databases vs. Vector Databases
Consider two requests on the same library website. One visitor enters a book’s catalog number. Another asks whether they can keep a book longer. The first request identifies a particular record. The second calls for a passage that addresses a question written in everyday language.
| Comparison | Field-based querying | Vector similarity search |
|---|---|---|
| Basic approach | Checks the values in specified fields. | Compares numerical representations of the query and the content. |
| Example request | Find the book with a particular catalog number. | Find the passage that addresses “Can I keep my book a little longer?” |
| What the result tells you | The record meets the stated condition. | The passage is close to the query according to the similarity measure. |
Both types of search can run in the same database. PostgreSQL, for example, can store vectors and perform similarity searches through the pgvector extension. The appropriate setup depends on how much content you have, how often it changes, and which systems you already use.
How text becomes a vector
An embedding model draws on patterns it learned from language to represent a piece of text as a sequence of numbers. A search system can then compare those sequences to find related questions and passages. With suitable models, the same approach can also be used for images or audio.
The individual numbers do not come with labels such as “topic,” “intent,” or “emotion.” Their values work together to form the representation. As a site owner, you can evaluate the result without interpreting those numbers. Try a question in a visitor’s own words and see which passage the system retrieves.
What Is an Embedding? A Meaning-Based Fingerprint
An embedding is the vector representation that the model produces. The “meaning fingerprint” comparison can help explain why related passages appear close together, but the representation can change with the model or the context in which a phrase appears.
In the library example, “renew my loan” and “keep my book longer” express a similar request. Yet “renewal is allowed” and “renewal is not allowed” also discuss the same subject. Both passages may appear in the results even though they give the visitor different instructions. To judge the match, you need to read the actual rule.
How Does Vector Search Work? Measuring Similarity
Vector search compares the query’s representation with the vectors stored for your content. Passages whose vectors are close to the query become candidates for the results. A system can use measures such as cosine similarity to calculate that closeness.
Search can compare a query with every record. For larger collections, it can also use approximate nearest-neighbor methods to retrieve candidates more quickly. Approximate search may miss some close matches. When evaluating a change, measure how long visitors wait and whether the passage they need still appears near the top.
A similarity score tells you how close the passage is to the query under the chosen measure. It does not tell you how likely an answer is to be correct. A library passage could be highly relevant to renewals but describe a different membership type. The visitor still needs the rule that applies to their loan.
AI Search Step by Step: Content, Passages, Vectors, Results
The first three steps prepare the library’s pages for search. The last two happen when a visitor asks, “Can I keep my book a little longer?”
1. Content is collected and text is prepared
The system extracts usable text from the pages or documents you add. On a “Borrowing Rules” page, headings, conditions, and relevant links should stay with the text they describe. If the heading “Short-term loans” disappears during extraction, its renewal instructions could be mistaken for the general rule.
2. Long content is divided into meaningful passages
A long page may be split into smaller parts called passages or chunks. This makes a specific section easier to find while giving the search system enough context to interpret it. For example, if a paragraph explains how to renew a book and the next sentence lists an exception, it can help to keep them together. No single chunk length is ideal for every document.
3. Passage vectors are generated and stored
The embedding model converts each passage into a vector. The database stores the vector with a reference to its source text. The library might also store the language, document type, and section title. Search can then be limited to a particular language or part of the collection when needed.
4. The visitor’s question is converted into a comparable vector
When someone asks “Can I keep my book a little longer?”, the system generates an embedding for the question too. Query vectors and content vectors need compatible representations. This usually means using the same model or a pair of models designed to work together.
5. Relevant content is retrieved and presented
The system retrieves passages close to the question and may apply filters or rank the candidates again. In our example, the visitor could see a link straight to “Renewing Loans,” even though the word “renew” never appeared in the question. Opening that section lets them check the instructions and any exceptions.
A question-answering system can also pass the retrieved text to a language model, which uses it to write a response. That next step is explained in our guide to retrieval-augmented generation (RAG).
Limits of Vector Search: Product Codes and Exact Matches
Suppose a visitor searches a store for the product code “AB-120.” The description for “AB-121” may be almost identical, yet it belongs to a different model. When the visitor gives an exact identifier, search should check the product-code field. The same principle applies to document numbers and catalog records.
Hybrid search can combine keyword matches with vector search, helping visitors find content by an exact phrase or by a description of what they need. Where a code must match exactly, a field filter or exact-match rule is still important. Our article on combining keywords and meaning in hybrid search shows how the two methods work together.
Conditions and exceptions also require care. A passage that says a library book can be renewed may go on to explain that the rule applies only if no one else has reserved it. If the retrieved passage ends before that condition, the visitor could receive incomplete instructions even though search found the right subject.
How to Evaluate Search on Your Website
Start with a small test list based on questions your visitors actually ask. For each one, record the source page, the section you expect search to find, and any condition that needs to appear with it. For the library question, “the borrowing policy” is a broad target. “The renewal instructions, including the exception for reserved books” gives you something specific to check.
- Different wording. Compare “renew my loan” with “Can I keep my book a little longer?” Do both searches find the relevant renewal instructions?
- Exact identifiers. Search for an existing product code or catalog number. Check whether the intended record appears ahead of records with similar numbers.
- Conditional information. Ask about an exception to a general rule. Check whether search retrieves the passage that explains when the exception applies.
- An unanswered question. Ask about something your sources do not cover. If the system offers a related passage, check whether it acknowledges that the requested detail is missing.
If results are weak, first locate the problem. If the source information is incomplete, improve the content. If the correct page never appears among the candidates, check that it was indexed. If the page is found but the exception is missing, inspect the passage boundaries and the text shown to the visitor. Retest the same questions after each change.
Keep each question, expected source, and observed result together. A report such as “The renewal search finds the right rule but leaves out the reservation exception” gives your technical team a case they can reproduce.
Preparing Your Content for Search With Sorchy
Sorchy answers visitor questions using content from your website and shows the sources behind its answers. You can use its source-management options to choose the pages and documents it should use. After updating an important page, try the same visitor question again and check that the cited passage reflects the change.
Frequently Asked Questions About Vector Databases
How do I test vector search on multilingual content?
Choose a question your visitors ask and identify the passage that answers it in each language you support. Ask the question naturally in each language, then check which passage comes back and whether it includes the same conditions. If visitors should also be able to search in one language and find a document written in another, test that separately. For example, ask about loan renewal in English when the relevant policy is available only in French, and check whether search retrieves the renewal section.
Do vectors update automatically when content changes?
That depends on the update workflow. Changed text must be processed again and the corresponding vectors refreshed. Confirm that deleted content is also removed from search records. Editing a web page and updating its search index can happen at different times.
What happens if the embedding model changes?
If the new model produces vectors in a different representation space, the existing content vectors need to be regenerated. Comparing new query vectors with old content vectors may produce unreliable results. Before completing the transition, run the same set of visitor questions and check that the expected passages are still retrieved.
Share this post
Written by sorchy team
Product updates, practical guides and how sorchy works under the hood.