Search Evolution Explorer
An interactive book about how search works

Hello. This is a book you can run.

It explains how a marketplace search engine works, in an introduction and eleven chapters. Each chapter is a small search engine that fixes one weakness of the chapter before it. You read a little, you press a button and watch real results change, you check the score, then you read the code that did it.

11 chapters you can run0 chapters read-only42994 catalog listings
Your first experiment · 20 secondssample data, 42994 listings

A buyer types “carpet”. The sellers wrote “rug”. The simplest search looks for the exact word.

← Flip the switch
394of 42994 listings matched
  1. 1supermat medium pile carpet beveled edge chair mat
  2. 2aramantha mid-back task chair
  3. 3hafsa velvet task chair
  4. and 391 more

This is the first weakness of the simplest search: the buyer and the seller do not use the same word.

How to read this book

  1. 1Read a littleEvery chapter has the same four short steps: start simple, where it breaks, the fix, what it is called. The term comes last, after you saw the behaviour.
  2. 2Press, then lookEach step has a play button that runs a real query against 42994 listings. The list on the page changes, and a note tells you why.
  3. 3Check the scoreEvery chapter ends with a checkpoint: the same answer key grades this chapter and the one before it, and one number tells you whether the search got better. The introduction shows how that number is built.
  4. 4Read the code that ranEach chapter ends in its own source file, with numbered notes beside the lines that matter. Open any function it calls, and come back with one key.

Contents

matching = which listings are found at all  scoring = the order they are shown in
  1. IntroIntroduction. How do we know whether a search is good?How we keep score. An answer key grades every result, and one number says how good a ranking is. Every chapter ends with that number.read first · 5 min
  2. 1Chapter 1. Show the newest listings firstRecency search. Retrieve strict word matches and order them newest first.matchingscoring
  3. 2Chapter 2. Meet the seller halfway on wordsQuery normalization. Normalize query words with stemmingCut a word to its stem, so that 'bikes', 'biking' and 'bike' all become 'bike' and match each other., synonymsAlso search for words with the same meaning, so 'couch' also finds 'sofa'. and spelling variantsTreat 'mid-century', 'mid century' and 'midcentury' as the same word., still ordered newest first.matching
  4. 3Chapter 3. Order by text fit, not by ageLexical match. Order the normalized candidatesAll listings that matched the query at all, before they are ordered. Scoring can only reorder this set. It cannot add to it. by how strongly their text matches, with BM25The standard formula that scores how strongly a listing's text matches the query words. A word counts more when it is rare in the whole corpus and appears often in this listing. Very long listings are penalised a little..scoring
  5. 4Chapter 4. What if I mistype a word?Spelling normalization. Correct misspelt query words against the listing vocabulary, then match the corrected words.matchingscoring
  6. 5Chapter 5. Name the attributes, not the seller's wordsEntity-tagged matching. Require every named attribute, but accept it in words or in listing fields.matchingscoring
  7. 6Chapter 6. Keep the rug, remove the rug padCanonical search policy. Filter or boostA hand-chosen number added to the score when a listing has a wanted property, for example the category the query points at. by canonical product typeOne shared product language for queries and listings: product type, brand, model and relations such as compatible-with. Chapter 6 maps both sides into it from hand-written tables, so a case and a phone stop looking the same. with a confidence-gated policyThe rule that turns a query annotation into FILTER, BOOST or FEATURE. High confidence plus trusted listings filters; medium confidence only boosts; unclear listings are never filtered..matchingscoring
  8. 7Chapter 7. Use what I meant, not only the words I typedAttribute boosting. BoostA hand-chosen number added to the score when a listing has a wanted property, for example the category the query points at. lexicalAbout the literal words. Lexical matching finds listings that contain the query words themselves, not their meaning. candidatesAll listings that matched the query at all, before they are ordered. Scoring can only reorder this set. It cannot add to it. with query attributes and static qualityA quality score that does not depend on the query, for example how new a listing is or how complete its title is. It can be computed once for every listing..scoring
  9. 8Chapter 8. Let data choose the weightsLearned ranking. Replace hand-tuned boostsA hand-chosen number added to the score when a listing has a wanted property, for example the category the query points at. with a linear modelA score computed as weight 1 × feature 1 + weight 2 × feature 2 + ... The weights are learned from data instead of chosen by hand. trained from chapter 7 clicks.scoring
  10. 9Chapter 9. Find the meaning, not only the wordsHybrid search. Widen matchingThe step that decides which listings are candidates at all. with precomputed document vectorsA list of a few hundred numbers that a neural network produces from a text. Texts with a similar meaning get vectors that point in a similar direction, even when they share no words. and fuse the two rankings.matchingscoring
  11. 10Chapter 10. Read the query and the listing togetherCross-encoder reranking. Read the query and each of chapter 9's first 50 listings together, then rerankTake a short list that is already ranked and order it again with a slower, more precise model. them.scoring
  12. 11Chapter 11. Teach the vectors what this catalog meansTwo-tower retrieval. Find new candidatesAll listings that matched the query at all, before they are ordered. Scoring can only reorder this set. It cannot add to it. with trained independent towers, then keep chapter 10's joint ranking.matchingscoring

Other pages: Compare two chapters on one query, the Scorecard over all test queries, Position bias, the trap of learning from clicks, and Beyond, where this book stops.