Beyond the database
Product search needs free text matching, relevance ranking, typo tolerance, and faceted filters like brand, price, and size. A relational database with LIKE queries cannot do this at scale, so stores use a dedicated search engine built on an inverted index.
The inverted index
An inverted index maps each term to the list of products that contain it. A query intersects these lists, which is far faster than scanning every row. The engine also computes a relevance score so the best matches rank first.
Faceted filtering
Facets are aggregations: for the current query, how many products fall in each brand or price band. Shoppers narrow results by clicking facets, and the engine recomputes the matching set and counts.
Keeping it fresh
The search index is derived data. Catalog changes flow in through an indexing pipeline, so the index is eventually consistent with the source of truth.
Key idea
Serve product search from an inverted index with relevance ranking and facets, kept fresh by an indexing pipeline.