AI product search, instant suggestions and a style bar on one engine
Natural-language product search for a Magento optical retailer, reading live store data, cached in Redis, and reused for type-ahead suggestions and a "similar frames" bar on product pages.
AI search · Recommendations · Redis caching · Magento integration
- product
- AI search and recommendations
- platform
- VARAi
- role
- CTO & forward-deployed AI engineer
Results
- Repeat queries served from the Redis cache, skipping AI routing and the store's API
- ~2 s → ~50 ms
- Scripted test suite, run side by side against the hosted search it replaced
- 107 queries
- Intent parsing (52), AI fallback (56), autocomplete (22)
- 130 unit tests
- Search, autocomplete and style bar services in five weeks: +3,807 / −1,518 lines
- 60 commits
Problems solved
01The store's own search was the bottleneck
- broke
- Magento's full-text search missed obvious matches, so any layer built on it inherited the misses.
- changed
- Search now runs on our own catalogue index; Magento is called only for live prices, stock and URLs by SKU.
- proof
- Products with a 3D model sort first, and every result links to a live product page.
02The model invented category IDs
- broke
- The AI router sometimes returned the right category name with the wrong ID, which produced empty or wrong results.
- changed
- IDs are cross-checked against the name in the catalogue map, and a zero-result category falls back to all products with the other filters kept.
- proof
- Accessories stay excluded on fallback, so "glasses" never returns cases and cloths.
03The cache served the wrong currency
- broke
- Cache keys ignored the store view, so every region got the first region's prices.
- changed
- Keys are now tenant + store view + query; session IDs are stripped from cached payloads and injected per request.
- proof
- Gulf store views return their own currency on cached hits.
04No Redis, unbounded memory
- broke
- Without Redis the in-memory fallback cache grew with every new query.
- changed
- The fallback is capped at 1,000 entries and evicts the oldest first.
- proof
- Search keeps working with or without Redis attached.
05Model numbers got buried
- broke
- A query like brand + model number ranked general brand results above the exact frame.
- changed
- The model number is extracted and exact name or SKU matches are boosted to the top.
- proof
- Model-number queries are part of the 107-query test set.
06Type-ahead was empty on new stores
- broke
- Suggestions were built from past searches, so a 27,000-product catalogue with no history returned brands only.
- changed
- A fourth source queries the catalogue directly and writes hits back into the Redis prefix index.
- proof
- The same fix removed a duplicated search overlay that blocked typing on click.
07Suggestions showed the wrong price
- broke
- The dropdown showed base-currency prices to shoppers paying in another currency.
- changed
- Price was removed from suggestions; converting it live would add a 200–500 ms store call per keystroke.
- proof
- Prices stay on the product page, where the store converts them.
08A "similar frames" bar on contact lenses
- broke
- The style bar appeared on contact-lens pages, where similar glasses make no sense.
- changed
- Eligibility now keys on optical frame types only, and picks stay within 0.4–2.5× of the current product's price.
- proof
- Four unit tests cover the contact-lens exclusion.
Put the AI where it adds judgement, keep live commercial data with the store that owns it, and cache everything in between with keys that match how the store is split.
stack · Node.js / Express · PostgreSQL (trigram search) · Redis · Claude Haiku (intent routing) · Magento GraphQL · PHP (Magento module) · JavaScript widgets · Jest
More from VARAi
- P-01AI Designer & Material StudioLive AI design chat · AI that acts, not just answers · 3D materials · Render automationChat → live 3DDesign mode changes materials, lighting and exposure in the scene; Apply or Reject each change in the chat
- P-02Lens JourneyDeterministic rules engine · Prescription upload · Catalogue sync · Multi-platform commerce1,500+ testsLens-journey suites, Sep 2026 (recorded runs of 1,431 and 1,772)
- P-03Virtual try-onBrowser AR · 3D rendering · Storefront integration · Production reliability38.3 s → 57 msOne documented gallery-query benchmark
- P-04Store analysis and catalogue syncCatalogue sync · Data mapping · Shopify · Magento · Human approval43 products · 1,605 variantsLive run on a heritage British eyewear store; 6 accessories excluded and named
Need a senior AI engineer who can own delivery?
Tell me what you're building and where it breaks. I reply to every message myself.
Contract CTO · Principal AI engineering · Forward-deployed AI engineering · Enterprise AI architecture