Blog/SEARCH & AI

Keyword vs Semantic Search (Lexical vs Vector): Which to Use

Giorgi Kenchadze

By Giorgi Kenchadze

Updated · 9 min read

Keyword (lexical) search matches exact words with BM25. Semantic search matches meaning. Vector search is how semantic search runs. Side-by-side examples and when to use hybrid.

Short answer: keyword search (also called lexical search) matches the exact words in a query using algorithms like BM25. Semantic search matches the meaning of a query, so "cheap laptop for school" finds "budget notebooks for college". Vector search is the technique most semantic search runs on: text is turned into embeddings and compared by similarity. Use keyword search for exact terms like SKUs and error codes, semantic search for natural language, and hybrid search when you need both.

Keyword (lexical) search Semantic search Vector search
Matches on Exact words and tokens Meaning and intent Numeric similarity between vectors
Typical algorithm BM25, TF-IDF Embedding model + vector search HNSW, IVF, cosine / dot product
Handles synonyms No Yes Depends on what the vectors encode
Exact codes and names Excellent Weaker Weaker
Examples Elasticsearch, Postgres full-text, Algolia Vecstore, Google Search pgvector, Pinecone, Qdrant, FAISS

Search is one of those things that seems simple until you build it. A user types a query, you return results. But how you match that query to your data makes all the difference between a search bar that frustrates users and one that feels like it reads their mind.

The two fundamental approaches—keyword search and semantic search—work in completely different ways, and understanding the distinction matters whether you're building search into a product, evaluating a search vendor, or trying to figure out why your users keep complaining that "search is broken."

How Keyword Search Works

Keyword search does exactly what the name implies: it matches the words in a query against the words in your documents. If a user searches for "running shoes," it finds documents that contain the words "running" and "shoes."

Most keyword search systems use a technique called TF-IDF (Term Frequency–Inverse Document Frequency) or BM25, which is the modern standard. These algorithms score documents based on:

  • How often the search terms appear in a document (term frequency)
  • How rare those terms are across all documents (inverse document frequency)
  • Document length normalization

If you've used Elasticsearch, Apache Solr, or even a basic SQL LIKE query, you've used keyword search.

Where Keyword Search Works Well

Keyword search is fast, predictable, and easy to understand. It excels when:

  • Users search for exact terms — product names, SKUs, error codes, legal citations
  • Your content uses consistent terminology — technical documentation, structured databases
  • You need transparent, explainable results — compliance-sensitive environments where you need to show why a result matched

Where Keyword Search Breaks Down

The problem is that human language is messy. People don't always use the exact words that exist in your data.

A user searching for "affordable laptop for school" won't match a document titled "Best Budget Notebooks for College" — even though it's exactly what they're looking for. Different words, same meaning. Keyword search misses it entirely.

This is the vocabulary mismatch problem, and it's the single biggest limitation of keyword search. Other common failures:

  • Synonyms — "car" vs. "automobile" vs. "vehicle"
  • Paraphrasing — "how to fix a leaky faucet" vs. "repairing a dripping tap"
  • Intent — "apple" could mean the fruit or the company, and keyword search can't tell the difference
  • Multilingual queries — a Japanese user searching for "軽量ノートパソコン" won't find English-language laptop listings

How Semantic Search Works

Semantic search understands the meaning behind words, not just the words themselves. Instead of matching strings, it matches concepts.

Under the hood, it works like this:

  1. An embedding model (a neural network) converts text into a high-dimensional vector — a list of numbers that represents the meaning of that text
  2. Similar meanings produce similar vectors. "Affordable laptop for school" and "budget notebook for college" end up close together in vector space, even though they share zero words
  3. At search time, the query is converted into a vector and compared against all document vectors using a similarity metric (usually cosine similarity)

This is why semantic search is sometimes called vector search — the core operation is comparing vectors.

Semantic Search vs Vector Search: Are They the Same?

Not quite, although the terms are often used interchangeably.

  • Semantic search is the goal: return results that match what the user means. It describes the behavior a user sees.
  • Vector search is a technique: find the stored vectors closest to a query vector. It describes the math under the hood.

Most semantic search today is built on vector search, but the two can come apart. Vector search can run on vectors that have nothing to do with meaning, like image pixels, audio fingerprints or user behavior. And semantic search can use more than vectors, such as re-ranking models, query rewriting or knowledge graphs.

A useful way to think about it: a vector database like pgvector or Pinecone gives you vector search. You still have to pick an embedding model, generate embeddings, keep them in sync with your data and tune ranking before you have semantic search. A semantic search API like Vecstore does all of that for you, so you send text and get ranked results back.

"Lexical search" is the academic name for keyword search. Lexical means "relating to words", so lexical search ranks documents by the words they share with the query. BM25 is the standard lexical ranking function, and it's what Elasticsearch, OpenSearch and Lucene use by default.

In research papers and retrieval benchmarks you'll see this framed as sparse vs dense retrieval:

  • Sparse retrieval (lexical): each document is a huge vector with one slot per word in the vocabulary, mostly zeros. BM25 works on these.
  • Dense retrieval (semantic): each document is a short vector of a few hundred to a few thousand numbers produced by a neural network, with every slot filled.

Dense retrieval usually wins on natural language questions. Sparse retrieval still wins on rare terms, names and codes the embedding model never saw during training, which is why the best systems combine them.

Where Semantic Search Works Well

Semantic search shines when users describe what they want in their own words:

  • Natural language queries — "something to keep my coffee hot during my commute"
  • Concept matching — finding related content even when the terminology differs
  • Multilingual search — modern multilingual models understand 100+ languages natively, so your Korean users can search in Korean and get accurate results from content in any language without per-language configuration
  • Vague or exploratory queries — users who don't know the exact term for what they're looking for

Where Semantic Search Has Limitations

Semantic search isn't universally better. It has trade-offs:

  • Exact matches can suffer — searching for a specific product code like "XPS-15-9530" might return semantically similar but wrong products
  • Less transparent — it's harder to explain why a particular result ranked high, since the matching happens in a 768-dimensional space that humans can't inspect
  • Requires ML infrastructure — you need embedding models, vector storage, and the compute to run inference (though managed APIs abstract this away)

Side-by-Side Comparison

Here's how the same queries play out with each approach:

Query Keyword Search Result Semantic Search Result
"affordable laptop for school" No match (no document contains these exact words) "Best Budget Notebooks for College"
"XPS-15-9530" Exact match found May return similar laptop models too
"how to fix a dripping tap" Matches only if "dripping tap" appears in content Also finds "leaky faucet repair guide"
"軽量ノートパソコン" (Japanese) No match in English-only content Finds "軽量ノートパソコンのレビュー" from Japanese content
"apple" Returns everything containing "apple" (fruit + company) Returns results biased by the model's interpretation of context

Neither approach wins every scenario. That's why many production search systems use both.

Hybrid Search: The Best of Both

The most effective modern search systems combine keyword and semantic search. This is called hybrid search, and it typically works by:

  1. Running both a keyword search (BM25) and a semantic search (vector similarity) in parallel
  2. Merging the results using a technique called reciprocal rank fusion or a learned re-ranking model
  3. Returning a final ranked list that captures both exact matches and semantic relevance

This way, a search for "XPS-15-9530" returns the exact product match at the top (thanks to keyword search), while a search for "lightweight laptop for travel" returns semantically relevant results even if those exact words don't appear in your product descriptions.

What This Means for Your Product

If you're building search into an application, here's the practical takeaway:

If your users search with exact, predictable terms — keyword search (Elasticsearch, PostgreSQL full-text search) is simple and effective. Don't over-engineer it.

If your users search in natural language, in multiple languages, or describe what they want rather than naming it — you need semantic search. This is increasingly the norm, especially in e-commerce, content platforms, and any user-facing search experience.

If you need both — and most products eventually do — look for a solution that supports hybrid search out of the box. Building your own hybrid pipeline (BM25 + embeddings + re-ranking) is doable but adds significant complexity.

A semantic search API like Vecstore handles the infrastructure for you — embedding generation, vector indexing, and ranked retrieval — through a simple REST API, so you don't need to manage models or vector databases yourself.

The Bottom Line

Keyword search matches words. Semantic search matches meaning. For years, keyword search was the only practical option because semantic understanding required expensive ML infrastructure. That's no longer true.

The tools have caught up to the ambition. If your users are searching with natural language — and they are — semantic search isn't a nice-to-have anymore. It's the difference between a search experience that works and one that feels broken.

FAQ

Is semantic search better than keyword search?

For natural language queries, yes. For exact identifiers like product codes, part numbers or names, keyword search is usually more precise. Most production systems combine both with hybrid search.

Is vector search the same as semantic search?

No. Vector search is the technique of finding the nearest vectors to a query. Semantic search is the outcome of matching by meaning. Most semantic search is powered by vector search over text embeddings.

What is lexical search?

Lexical search is another name for keyword search. It ranks results by the words they share with the query, most commonly using the BM25 algorithm.

Do I need a vector database for semantic search?

Not necessarily. You can run a vector database yourself, add pgvector to Postgres, or use a managed semantic search API that handles embeddings and indexing for you. See do you need a vector database? for the trade-offs.

What is hybrid search?

Hybrid search runs keyword and semantic search together and merges the results, usually with reciprocal rank fusion. It keeps exact matches at the top while still catching queries phrased in different words.

← Back to all posts

Better search for your product without the engineering overhead.

3–4ms average search latency

Sign up for Vecstore
Start for Free

100 Free credits. No credit card required.