advancedTop 30 Scenario-Based Questions
How would you implement auto-complete search using Redis?
Redis Sorted Set for prefix search: 1) Indexing: for each product 'MacBook Pro', add all prefixes: ZADD autocomplete 0 'mac', 0 'macb', 0 'macbo', ... 0 'macbook pro', 0 'macbook pro#100' (terminator + productId). 2) Search: find prefix range: ZRANGEBYLEX autocomplete '[macb' '[macb\xff' LIMIT 0 5. 3) Returns: 'macbook', 'macbook pro#100' — extract full terms. 4) Better approach: Store prefix → li
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
How would you implement auto-complete search using Redis?