Filter counts update dynamically reflecting current filter intersection
Why it matters
Filter counts that show global totals instead of intersected totals (ISO 25010:2011 functional-suitability) actively mislead users. A user filtering by "Restaurants" who then sees "Rating: 4+ stars (847)" expects that number to reflect restaurants with high ratings — if it still reflects all 847 rated listings in the directory, they'll apply the filter expecting hundreds of results and land on a handful. This mismatch generates rage-clicks, support tickets, and abandoned sessions. The data contract between UI label and backend query must be exact: a count badge is a promise.
Severity rationale
High because stale global counts misrepresent the result set, causing users to make filter decisions based on incorrect data and destroying trust in the search experience.
Remediation
Expose a /api/listings/filter-counts endpoint that accepts all active filter params and returns counts scoped to their intersection. Call it every time the active filter set changes.
// /api/listings/filter-counts
export async function GET(req) {
const category = req.nextUrl.searchParams.get('category')
const baseWhere = { category } // extend with all active filters
return Response.json({
ratings: {
'5': await countListings({ ...baseWhere, rating: 5 }),
'4plus': await countListings({ ...baseWhere, rating: { gte: 4 } }),
}
})
}
On the frontend, trigger a refetch of filter counts inside the same effect that fires when any active filter changes, and update the displayed badge values from the response.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Search & Discovery UX Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · functional-suitability — Functional Correctness
Taxons
History
- 2026-04-18·v1.0.0·Initial import from directory-search-discovery·automated