Problem
Consumer search is one box that answers on every keystroke and must survive mobile typos. The engine sees only the first letters of the last word, sometimes misspelled, and still has to rank the wanted record first. Standard full-text features break here: fuzzy queries are too slow, and n-grams cannot tell a whole word from a prefix. Adding popularity or price can bury the record the user typed.
Example from the article: a query for "jon" is an exact match for people named Jon and a one-letter typo for John and Joan. Jon must rank first, and John and Joan must still appear.
Solution in brief
Treat text relevance and promotion as ordered layers. First guarantee that exact beats prefix and exact beats typo, then break ties with a business signal. On Elasticsearch, build this from edge n-grams, shingles and a tuned minimum_should_match. Algolia applies ranking criteria in turn, with no score coefficients.
Questions this case answers
- How to rank results for partial, misspelled queries so that exact matches always come first and business signals only break ties
- How to keep a query-time tolerance parameter from producing either zero results or irrelevant results
- How to make as-you-type product search forgive typos and partial words without burying exact matches?
- How to combine text relevance with popularity or price signals so promotion never overrides what the user typed?
Tools and methods
- Elasticsearch (Lucene) — framework to assemble multi-field, prefix and typo-tolerant search
- Edge n-grams — index word prefixes for as-you-type matching
- Shingles — index word pairs so word order affects ranking
- minimum_should_match — how many query words a record must contain
- Completion Suggester — fast single-field instant suggest
- Algolia ranking formula — ordered criteria used as tie-breakers instead of a score
Google or a one-time email code. No password.