Get list of all facets & its values

Hi there,

I am using components of React InstantSearch, and I would like to get the list of all facets & its value. I can’t find a component for this, and I can’t find either this information in Algolia response payload.

To illustrate what I want to achieve: let’s say I have configured in the dashboard the following facets:

  • Brand
  • Size
  • Certifications

I would like to have a list of all values as follows, so I can refine & filters the results:

Brand:

  • brand1
  • brand 2

Size:

  • size1
  • size 2

Certifications

  • certification1
  • certification2

Is there a way to achieve this with Instant Search ?

Thanks!

Hi @Ludovic,
You can use our RefinementList widget.

For example: <RefinementList attribute="brand" /> will show you the lists of brands.

So in your case; you’d have to use:

<RefinementList attribute="brand" />
<RefinementList attribute="size" />
<RefinementList attribute="certifications" />

Make sure each attribute is declared as a facet in your index configuration. (there are many ways to do it)

For filtering the results, you can use transformItems prop exposed.

Does this help?

1 Like

Thanks for your reply!

So there is no way to automatize this ? I mean, to get the list of all available facets (brand, size, certifications - and any other that I would like to add via the dashboard).

Because this way, adding RefinementList for each facet, I will have to re-deploy my app every time I add a new facet. I would like to avoid that

Hi @Ludovic,

Indeed, using InstantSearch it is as @Youcef described.

However, if you would simply like to collect this data you can make the facets request using your preferred API client to retrieve the facet values: https://www.algolia.com/doc/api-reference/api-parameters/facets/

1 Like

Got it! Thanks!
I’ll use the API instead of InstantSearch then.

1 Like