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’s product.catalog.updated (product lifecycle fields) and inventory-service’s inventory-search-event (coarse price/stock summary), stock-balance-status-changed (per-SKU stock status, ordered by product ID), and sku-compliance-pricing-upserted (per-SKU pricing, ordered by transaction ID, filtered to status == "COMPLETED") — and denormalizes each into its own product_search collection. See SR-006 FR-14–FR-18, ADR-00017, and Architecture-00006’s sync section for the full breakdown.
  • Keeps product_search converged 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-changed keyed by product ID, sku-compliance-pricing-upserted keyed 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-upserted topic is shared with product-catalog’s publish-readiness gate, but via search-service’s own independent subscription — the two consumers never see each other’s ack/cursor state, and search-service additionally filters to status == "COMPLETED" only, discarding the same operation’s PROCESSING/FAILED events.
  • search-service has no write path back to product-catalog/inventory-service — it is a read-optimized projection only.
  • search-service never calls shop-service — the gRPC relationship is one-directional, shop-service → search-service only (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_search freshness for the affected product/SKU, tracked as Technical-Debt-00006, TD-06.

Architecture overview: Architecture: Scalable Search Product.