How semantic search works
Classic keyword search (BM25, TF-IDF) ranks documents by how often the query words occur. That
works for exact queries (“iPhone 15 Pro 256gb”) and breaks on descriptive ones (“what to pack for
a three-day hike with kids”).
Semantic search solves that through embeddings:
- A language model (BERT, E5, multilingual-E5 and others) encodes the query into a numeric vector
— a point in a many-dimensional space. - Every product in the catalogue is encoded into a vector as well and stored in a vector database.
- On search, the system finds the products whose vectors are nearest to the query vector — by
cosine distance or dot product.
Query: "warm sneakers for winter"
Query vector: [0.23, -0.14, 0.87, ...]
Nearest products:
- "Insulated Gore-Tex sneakers" (similarity: 0.94)
- "Salomon winter boots" (similarity: 0.91)
- "Fleece-lined sneakers" (similarity: 0.89)
Hybrid search: the best of both worlds
In practice most production systems run hybrid search — a combination of keyword and semantic:
| Method | Strengths | Weaknesses |
|---|---|---|
| Keyword (BM25) | Exact SKUs, brands, numbers | No grasp of synonyms, no typo tolerance |
| Semantic | Synonyms, conversational queries, intent | Can blur precise queries |
| Hybrid | Precision plus meaning | Weight tuning is harder |
The hybrid approach blends keyword results and semantic results with weights (60/40, for example)
or through a reranking model.
Where it applies in e-commerce
- Fewer zero results. A 50,000-product catalogue on keyword search returns 10–15% zero
results. Semantic search surfaces the nearest alternatives instead. - Long-tail queries. 70–80% of search queries are unique — never typed before. Semantics
handles them with no special configuration. - Multiple languages. Models such as multilingual-E5 read queries in different languages
inside one shared vector space. - Visual search. Multimodal models encode images and text into a shared space, so a shopper
can search by photo instead of by description.
Tip: rolling out semantic search is an addition to your existing search engine, not a
replacement for it. Start with a hybrid setup and an A/B test — semantic vs existing — on real
traffic.