AI / Engineering journal

Keyword Search vs Semantic Search

Semantic search is not a straight upgrade on keyword search. A plain look at what each does well, where each breaks, and how to combine them without guessing.

Sylantix Engineering Team7 min read
A laptop displaying document search results beside printed source pages.
Sylantix / Engineering journalSearch · AI · RAG
In this article 9 sections
TL;DR

Key takeaways

  • Keyword search is still the right tool for exact things: product codes, names, error messages and anything users filter by.
  • Semantic search finds results that mean the same thing in different words, but it is vague about exact terms and hard to explain.
  • Hybrid search runs both and merges the results; a re-ranker then puts the best few on top. That combination beats either alone in most products.
  • Judge search on a list of real queries with known good answers, not on a demo with queries someone picked to look good.

Product codes and descriptive queries

A shopper searching for "a jacket that keeps me dry on a bike" may need results labeled "waterproof cycling shell". Someone entering a product code needs an exact match. These queries ask different things of the search engine.

Keyword search and semantic search each handle part of that problem. Comparing their behavior on your own queries helps you decide whether to use one or combine them.

How keyword search works

Keyword search builds an index of the words in your documents: which words appear, where, and how often. When a query arrives, it looks up those words and scores documents by how well they match, usually giving more weight to rare words and to matches in titles. The classic scoring method, BM25, has been the backbone of search engines for decades for a reason. It is fast, cheap and predictable.

Where it is still the best tool

  • Exact identifiers. Order numbers, SKUs, invoice references, error codes. A user typing one of these wants that exact thing and nothing similar.
  • Names. People, companies, product lines and places. "Hartley" should find Hartley, not someone with a similar-sounding role.
  • Filters and facets. Size, price range, date, category. These are structured fields, and treating them as fuzzy meaning only makes results worse.
  • Explainability. When a result appears, you can say why: it contains the words. Support teams and auditors like that.

Where keyword search breaks

Keyword search only knows the words, not what they stand for. It misses synonyms ("car" versus "vehicle"), paraphrases ("cancel my plan" versus "end subscription"), and questions phrased the way people talk. You can patch this with synonym lists and stemming, and teams have done so for years, but those lists grow without end and never cover the way real users write.

What semantic search adds

Semantic search turns text into embeddings: long lists of numbers produced by a language model, arranged so that texts with similar meaning end up close together. Your documents are embedded once and stored in a vector index. Each query is embedded the same way, and the engine returns the documents whose vectors sit nearest to it.

The effect is that "jacket that keeps me dry on a bike" lands near the waterproof cycling shell, even though they share almost no words. The same works across languages to a degree, and for long, conversational questions that keyword engines handle badly.

Where semantic search breaks

  • Exact terms blur. Embeddings capture the gist, so codes, numbers and rare names get smoothed into "something like this". The SKU problem above is typical.
  • It always returns something. A vector search finds the nearest neighbors even when nothing relevant exists. Without a threshold, users get confident-looking results that are simply the least wrong.
  • Hard to explain and tune. You cannot point to the matching word. When a result is wrong, the fix is rarely obvious.
  • Chunking matters. Long documents have to be split before embedding. Split them badly and the right answer is cut in half across two pieces, neither of which matches well.

Hybrid search: run both

In most products the answer is not either one. It is both, run side by side.

A hybrid setup sends the query to the keyword index and the vector index at the same time, then merges the two result lists. A common merging method, reciprocal rank fusion, simply rewards documents that rank well in either list, which works surprisingly well without much tuning. Exact matches for codes and names come through from the keyword side; paraphrased and conversational queries come through from the semantic side.

Re-ranking: the step people skip

Merging gives you a decent top fifty. A re-ranker decides the top five. It is a second, slower model that reads the query and each candidate together and scores how well they fit. Because it only looks at a short list, its cost stays manageable, and it often makes the biggest visible difference to quality.

A practical pipeline usually looks like this:

  1. Apply hard filters first: category, language, permissions, stock.
  2. Retrieve candidates from both keyword and vector indexes.
  3. Merge the two lists.
  4. Re-rank the top candidates.
  5. Cut anything below a relevance threshold, so a bad match is shown as no match.

Step five is the one that keeps semantic search honest. Showing "no results, try different words" is better than showing five unrelated items with confidence.

How to measure search quality

Search quality arguments tend to run on anecdotes: someone tried a query, it looked bad, and now the whole system is in question. The cure is a test set.

Collect a hundred or so real queries from your search logs or support tickets. Include the boring ones, the misspelled ones, the codes and the vague questions. For each, write down which results a good answer must contain. Then measure how often the right result appears in the top three or top ten.

With that list you can compare keyword, semantic and hybrid on your own data instead of on a vendor's demo, and you can check that a change to chunking or to the re-ranker made things better rather than just different. Rerun it whenever something changes.

What each one costs to run

Keyword search is cheap. The index is small, queries take milliseconds, and it runs comfortably next to the database you already have. Semantic search adds three costs: embedding every document once and again whenever it changes, storing the vectors, and embedding every incoming query. A re-ranker adds a model call per search on top.

None of this is prohibitive for most products, but it changes how you design. Embed documents in the background when they are saved, not on every search. Cache embeddings for frequent queries. Keep the re-ranker to the top few dozen candidates. And watch latency: a search box that takes two seconds feels broken, however good the results are.

Where the choice matters most

E-commerce

Shoppers search with codes and brand names, and also with needs: "gift for a runner", "quiet dishwasher". The first group needs keyword precision and filters; the second needs semantic matching. Hybrid search with strict filters on stock and size is the usual answer. Measure it on revenue per search, not just clicks.

Customer support

Customers describe problems in their own words, rarely in the words your help articles use. Semantic retrieval helps here, but error codes and product names still need exact matching. If search feeds a chatbot, retrieval quality sets the ceiling for every answer it gives, which is why our RAG development work starts with search, not with the model.

Internal documents

Company wikis mix policy text, meeting notes and spreadsheets, with permissions on top. The search has to respect who may see what before ranking anything. Hybrid retrieval with permission filters applied first is the safe default.

Common mistakes

  • Replacing keyword search outright. Teams switch to vectors, then discover that order numbers stopped working. Keep the keyword index.
  • No relevance threshold. Semantic search with no cut-off fills the page with near misses.
  • Embedding whole documents. A forty-page PDF as one vector matches everything a little and nothing well.
  • Testing on the demo queries. The queries that impressed in the pitch are rarely the ones customers type.

Compare results on your own queries

Pull your fifty most common searches and your fifty most frustrating ones from the logs. Run them through what you have today and note where the right answer lands. If codes and names already work and paraphrases fail, add a semantic index alongside the keyword one rather than instead of it. If adding search to an existing product is the plan, our LLM integration page explains how we wire it in without touching the core of the app.

Facing this in your own product?

Describe your situation in a few sentences. Our engineering team replies within 24-48 hours on business days, and the first 30-minute consultation is free.

Sylantix Engineering Team

Written by the senior engineers who build these systems for clients: backends, AI features, mobile apps and the infrastructure under them. Questions about your own case go straight to them.

About the team →