The interview problem
A product search offers brand, size and color filters. Design facet counts that show useful alternatives while respecting visibility rules and remaining consistent with the result list.
Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.
1. Scope and assumptions
Define disjunctive facets: the count for a color ignores the selected color but retains the query, other selected dimensions and all authorization filters. Clarify whether counts are exact, approximate or capped.
2. Architecture and decisions
Query and identity → mandatory visibility filter → per-facet filter sets → counts and hits → snapshot response
Build one trusted base predicate for tenant, permissions and searchable status. For each facet, apply the base plus other selected dimensions; apply every selected dimension to the hits. Never remove authorization while removing a user-selected filter. Return counts and hits from a consistent index view where supported, with a version or freshness timestamp.
Avoid one unbounded query per possible value. Use bounded aggregations and explicitly handle high-cardinality attributes. Cache by normalized query, selected filters, authorization scope and index version. A public count cache cannot safely serve personalized visibility. For expensive facets, show a loading state or omit counts rather than fabricate zero.
3. Work through the example
An authorized catalog contains red-small: 8, blue-small: 12 and blue-large: 5 items. Selecting small and red returns 8 hits. The color facet, retaining small but ignoring red, shows red 8 and blue 12. The size facet, retaining red, shows small 8 and large 0. These are conditional counts, not global totals.
4. Failure cases and trade-offs
Applying every filter to every facet hides valid alternatives. Applying too few filters exaggerates counts or reveals private inventory. Distributed aggregations may be approximate; communicate that contract. Exact counts increase query cost, while stale cached counts can lead users to empty result pages.
5. Validation and acceptance
Use a tiny hand-counted catalog with private rows, multiple selections and zero-result combinations. Verify that changing an unauthorized row cannot change any visible count. Compare cached and uncached responses and test updates between pagination requests.
6. Follow-ups and self-review
How would OR within one dimension and AND across dimensions work? Reward explicit count semantics, invariant permission filters and an honest precision/freshness contract.
Sources and related practice
Elasticsearch documents that post_filter affects hits but not aggregations; this multi-facet permission design is original.
Read the primary technical reference
Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.
Continue with Search Ranking System Design: Retrieval, Ranking and Evaluation; Design retrieval over rapidly changing documents.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.