I’m implementing faceting on my Typesense collecti...
# community-help
s
I’m implementing faceting on my Typesense collection for fields like
brand
,
product_type
, and
size
. Faceting works well, but I’ve noticed an issue. When a user filters by a specific brand (e.g.,
brand: Nike
), the facet counts for
brand
in the response only include the selected brand (
Nike
) and its count. This means users can’t see or select other available brands unless they remove the brand filter. Is there a way to display all possible brand facet options (and their counts) even after a brand filter is applied - so users can easily switch between brands or see what else is available?
f
You have to make two requests inside a multisearch. One will have the
filter_by
applied and the other will not. e.g.
Copy code
{
  "searches": [
    {
      "query_by": "name",
      "sort_by": "_text_match:desc",
      "highlight_full_fields": "name",
      "collection": "games",
      "q": "*",
      "facet_by": "hltb_single,negative",
      "filter_by": "hltb_single:>=25",
      "page": 1,
      "per_page": 6
    },
    {
      "query_by": "name",
      "sort_by": "_text_match:desc",
      "highlight_full_fields": "name",
      "collection": "games",
      "q": "*",
      "facet_by": "hltb_single",
      "page": 1
    }
  ]
}
Notice that they're the exact same, the only difference between the two is the
filter_by
value being applied to the first one
It's how we do it on the Instantsearch adapter to keep displaying the rest of the facet counts when a filter is active