Search-Service — Denormalized Product Search Index
By Engineering Team•September 25, 2026•4 min read
Responsibility
search-service gives the mobile storefront a single, fast, pre-joined place to search published products — instead of the storefront querying product-catalog and inventory-service separately at search time.
- Subscribes to four independent Pub/Sub streams, not one unified event source:
product-catalog’sproduct.catalog.updated(product lifecycle fields) andinventory-service’sinventory-search-event(coarse price/stock summary),stock-balance-status-changed(per-SKU stock status, ordered by product ID), andsku-compliance-pricing-upserted(per-SKU pricing, ordered by transaction ID, filtered tostatus == "COMPLETED") — and denormalizes each into its ownproduct_searchcollection. See SR-006 FR-14–FR-18, ADR-00017, and Architecture-00006’s sync section for the full breakdown. - Keeps
product_searchconverged to each product’s current descriptive data, price, and availability, within a bounded delay of the underlying event being published. - Serves the mobile app’s keyword search and typeahead queries directly from this denormalized collection, ranked via a MongoDB Atlas Search index rather than a plain field match — see Architecture-00006 for the query mechanics and ADR-00007 for why Atlas Search was chosen over a standalone search engine.
(Correction: this section previously stated “no request-time join against product-catalog/inventory-service is needed for a search result.” That’s inaccurate for the default global search path — search-service returns matched product IDs only; shop-service’s GlobalSearchStrategy always performs a request-time gRPC join against both services to hydrate those IDs into displayable products. Tracked as Technical-Debt-00006, TD-04.)
Tech Stack
| Concern | Choice |
|---|---|
| Data store | Denormalized product_search collection, with a MongoDB Atlas Search index (product_search_index) for ranked keyword search |
| Messaging | Firebase Pub/Sub — four independent subscriptions: product.catalog.updated-search-service, inventory-search-event-search-service, stock-balance-status-changed-search-service (ordered, keyed by product ID), sku-compliance-pricing-upserted-search-service (ordered, keyed by transaction ID, COMPLETED-status filtered) |
| Read surface | gRPC ProductSearchService/SearchProducts (IDs + count, consumed by shop-service); REST GET /client/api/v1/product/full-search (typeahead suggestions, consumed directly by ui-application) |
Data Model
| Collection | Purpose |
|---|---|
product_search |
One denormalized document per published product — descriptive fields plus current price/availability, rebuilt incrementally from incoming events rather than joined at query time |
Implementation Notes
- Because indexing is event-driven, a search result can briefly lag the true state of a just-published or just-edited product — a bounded eventual-consistency window, not the same mechanism as
product-catalog’s own sync markers in ADR-00005 (see the correction note on SR-006 NFR-03 — the two are separate mechanisms, only one topic is genuinely shared). No measured delivery-latency figure exists yet. - Two of the four streams enable Pub/Sub message ordering (
stock-balance-status-changedkeyed by product ID,sku-compliance-pricing-upsertedkeyed by transaction ID) because an out-of-order event on either would leave a SKU’s stock/pricing state actively wrong, not just stale — see ADR-00017 for the full ordering rationale. The other two streams don’t need ordering — each event is closer to a full snapshot than a delta. - The
sku-compliance-pricing-upsertedtopic is shared withproduct-catalog’s publish-readiness gate, but viasearch-service’s own independent subscription — the two consumers never see each other’s ack/cursor state, andsearch-serviceadditionally filters tostatus == "COMPLETED"only, discarding the same operation’sPROCESSING/FAILEDevents. search-servicehas no write path back toproduct-catalog/inventory-service— it is a read-optimized projection only.search-servicenever callsshop-service— the gRPC relationship is one-directional,shop-service→search-serviceonly (see SR-005 NFR-05).- None of the four upstream publishers guarantee delivery beyond logging a failure — a sustained publish outage on any stream can silently stall
product_searchfreshness for the affected product/SKU, tracked as Technical-Debt-00006, TD-06.
Architecture overview: Architecture: Scalable Search Product.