Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Search Filter Count

Problem

We need to display filter counts on the search results page so users can see how many results match each filter option before applying it.

Case 1:

Use aggregation in the search query similar to booking.com: https://www.booking.com/city/id/jakarta.id.html This method can’t be applied to our current filter logic, which selects filters within a tag group (e.g. cuisine) using OR logic. OR logic prevents aggregation because filters combine disjunctively. This works great when all filters are using AND logic, similar to booking.com. Conclusion: Unless we change the filter logic to AND, it’s not applicable.

Branch:

Status: FAILED

Case 2:

Use a different query to aggregate the filter count based on search parameters (keyword, filter, etc.). This works but adds a little complexity to our codebase.

Commits:

Status: SUCCESS

I have searched the internet, but based on the research, this is the only viable approach I have found. Please let me know if you have a better solution for this.

Comparison

Case 1 is simpler but unusable; Case 2 is more complex but feasible.

Conclusion

Case 2 (the aggregation query approach) is the recommended path forward because it works with our existing OR-based filter logic.

Next Steps

Roll out in the next sprint after review and test coverage.