Problem
A grocery marketplace needs search that returns the right product for short queries across many stores. A query like «perets» (pepper) must surface red, black and bell pepper, not milk, and an empty results page is the worst outcome. In SberMarket (now Kuper), 7 of 10 products added to the cart come from Search-owned sections, so small changes visibly move the business.
Example from the article: a user searches «koka-kolu banan» but no banana-flavored Coca-Cola exists. Searching each word separately returns a mix of cola and banana products, better than an empty page.
Solution in brief
Search runs in two stages. Elasticsearch selects products matching the normalized, synonym-expanded, spell-corrected query and pre-ranks them by BM25 multiplied by how often the product was bought for that query. The top 300 go to an XGBRanker model trained on 0 to 4 labels built from cart and purchase events.
Questions this case answers
- How to retrieve and rank items for a free-text query when the only relevance signal is implicit user behavior
- How to build graded relevance labels for a ranking model from logged interaction events without human annotation
- How to build a grocery search pipeline from query to ranked results with an index plus a learning-to-rank model?
- How to turn cart, purchase and view events into graded relevance labels for a search ranker?
Tools and methods
- Elasticsearch — index with shards, index-time and query-time analysis, inverted index
- BM25 — text proximity between query and product fields
- Query rewriting — stop-word removal, morphological normalization, synonyms, spell checker, query relaxation
- XGBoost (XGBRanker) — learning-to-rank model over the top 300 candidates
- Negative sampling — products the user could have seen but did not, to fill each results page to 100
- NDCG@k, MAP@k — offline quality metrics
Google or a one-time email code. No password.
