← Lessons

quiz vs the machine

Gold1360

System Design

Faceted Search and Filters

Letting users narrow results by structured attributes while seeing live counts.

5 min read · core · beat Gold to climb

Facets versus filters

A filter restricts results to a condition, such as price under fifty. A facet is the set of available values for an attribute together with a count of how many matching documents fall into each value. Facets power the clickable sidebar on a shopping site.

Filters do not score

Unlike a ranked query, a filter is a yes or no test. Because it has no score and is reused often, the engine can cache its result as a bitmap. This makes filters cheap and lets them combine quickly with boolean and operations.

Computing facet counts

After applying the query and filters, the engine aggregates over a field, grouping matching documents by value and counting each bucket. A subtle rule of good faceting is that selecting one value in a facet usually should not shrink the counts shown for other values in that same facet, so users can switch choices freely.

Key idea

Faceted search pairs cheap cacheable filters with per value counts, letting users refine results while always seeing how many items each choice yields.

Check yourself

Answer to earn rating on the learn ladder.

1. What distinguishes a facet from a plain filter?

2. Why can filters be cached as bitmaps?