facetingAfterDistinct is not showing the correct values

I am using the instantsearch.js (vanilla javascript) library and I think the facetingAfterDistinct search parameter is not providing the expected results.

I followed along with this tutorial pretty much the whole way (except modifying the values to use my search index).

When I do a search (or browse the index), the facet counts are not based on distinct values.

I did check to see that I have marked the appropriate attribute as distinct.

This is how I invoke it in my search:

const searchClient = algoliasearch(

const search = instantsearch({
  indexName: 'papers_dev',
  searchParameters: {
    facetingAfterDistinct: true,

What the results look like:

Before selecting a facet:

After selecting a facet:

Am I missing something obvious? How can I get the correct number to show up in the facet count?

I got an answer from Algolia support (a few days back actually) and forgot to update this thread.

The answer is to configure a search refinement like it is done here.

    // You can provide any search parameter supported by the engine:
    facetingAfterDistinct: true,
    hitsPerPage: 4,
    container: '#searchbox',

1 Like