Skip to content
tezvyn:
Menu

Semantic Search: Finding Meaning, Not Just Keywords

Source: Wikipedia: Semantic searchMediumHow cards are made

Semantic search finds meaning, not just keywords. It's like asking a librarian for 'books about space travel' and getting results for 'astronaut biographies,' not just titles with the exact words. It's used in search engines to find conceptually related items.

Why it exists

Traditional search, or lexical search, is brittle. It relies on exact keyword matches. If you search for 'fast laptop for travel,' it might miss a great review titled 'the quickest ultrabook for digital nomads' because the words don't match. Semantic search was created to bridge this gap between user intent and literal text.

The mental model

Think of it as a search engine with a thesaurus and a sense of context. Instead of just matching strings of characters, it maps your query and the documents into a shared 'meaning space.' In this space, 'fast laptop' and 'quick ultrabook' are neighbors, even though the words are different. The search is for proximity in this meaning space, not for keyword overlap.

How it works

Modern semantic search converts text—words, phrases, or entire documents—into numerical vectors called embeddings. A machine learning model, trained on vast amounts of text, learns to place items with similar meanings close to each other in a high-dimensional vector space. When you search, your query is also converted into a vector. The system then finds the document vectors in its index that are closest to your query's vector, returning those as the most relevant results.

When to use it

Use semantic search when user intent is more important than specific keywords. This is common in general web search, e-commerce ('summer dresses' should show sundresses), and question-answering systems where a user's phrasing can vary widely. It's ideal for discovery and exploration.

When not to use it

Avoid it when precision and literal matches are critical. For example, searching for a specific error code, a legal clause, or a function name in a codebase. In these cases, a traditional lexical search is more reliable and predictable because you want an exact match, not a 'conceptually similar' one.

One canonical example

A user searches an e-commerce site for 'something to keep my coffee hot on the go.' A lexical search would fail, finding no products with that exact phrase. A semantic search understands the intent. It converts the query into an embedding that represents the concept of portable, insulated beverage containers. It then finds products whose descriptions have similar embeddings, like 'Thermos' and 'insulated travel mug,' and returns those.

Interview question

Which scenario best illustrates the primary advantage of semantic search over traditional lexical search?

  • a.Identifying a specific error code in a system log.
  • b.Discovering products on an e-commerce site using a descriptive phrase like "something to keep my coffee hot on the go."Correct
  • c.Finding a function definition using its precise name in programming documentation.
  • d.Retrieving legal documents by their exact citation numbers.
Why?

Semantic search excels at understanding user intent and conceptual meaning, even when exact keywords are not present, making it ideal for discovery with descriptive queries. Options A, B, and C describe situations requiring precise, literal matches, where lexical search would be more appropriate.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles