Problem
Trendyol's search team keeps a corpus of suggestion terms (brands, categories, merchants, campaigns, product attributes and more) shown while a user types. A nightly Airflow pipeline rebuilt the whole corpus in BigQuery. Term generation from product queries alone scanned 14 billion rows a day and used up all allocated BigQuery slots, so some queries ran up to 24 hours at peak. Adding a brand, refreshing a term score or removing a term with no matching products each meant waiting for a full rebuild. The business logic was spread over many SQL queries, which made the pipeline hard to change and test.
Example from the article: if no products are left in the "dress" category, "dress" must stop being suggested in near real time.
Solution in brief
Generate product-based terms outside BigQuery from product-database change events. Keep the corpus in one Couchbase bucket where each component (term generators, scoring, enrichment) updates only the fields it owns by partial update. BigQuery stays only for scoring, and the bucket is indexed into Elasticsearch.
Questions this case answers
- How to keep a derived lookup corpus fresh when a full batch rebuild over billions of rows takes up to a day and blocks every small update
- How to split a monolithic batch pipeline into independently updated components that each own part of a shared record
- How to keep a search-suggestion corpus fresh when a daily warehouse pipeline takes up to 24 hours?
- How to add or change one suggestion term, or refresh its score, without rerunning the whole pipeline?
Tools and methods
- Couchbase — corpus store with sub-document partial updates and DCP change events
- Go DCP client — listens to product changes and drives per-product term generation and indexing
- BigQuery — still runs term scoring, now independently of the rest
- Elasticsearch — suggestion index behind the Suggestion API
Google or a one-time email code. No password.