Andrea Favero
Andrea Favero

Reputation: 202

Algolia instantsearch.js: how to get all facets

I'm using instantsearch.js v4 and I'm trying to get a list of all facets configured in a index. (the ones defined in the Algolia dashboard)

There's a way to do that?

I'm not trying to get

 - Color:
   - green
   - red
   - ...

But what i'd like to get is:

 - Color
 - Size
 - (all the other facets)

Upvotes: 0

Views: 840

Answers (1)

Chuck Meyer
Chuck Meyer

Reputation: 381

You can retrieve a list of all facets and record counts by passing the API a wildcard:

index.search('', {
  facets: ['*']
});

The list of facets and record counts will be in facet_stats

Docs: https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#retrieving-facets

Upvotes: 0

Related Questions