Instantsearch.js: numericRefinementList should hide non relevant options

Created on 12 Jul 2016  路  8Comments  路  Source: algolia/instantsearch.js

If the current search shows that there are now results with rating < 50 then we should hide rating < 50 or indicate it's not relevant (gray).

Previous discussion: https://github.com/algolia/instantsearch.js/issues/1132#issuecomment-231929602
Relevant code to fix: https://github.com/algolia/instantsearch.js/blob/f5f90641a739a522b6d90cd67cffb4d1d368936c/src/widgets/numeric-refinement-list/numeric-refinement-list.js#L104

Double check that all numeric lists are also not impacted.

Widgets Bug

Most helpful comment

@beHappyBeLindy I ended up with adding a from-to price_range attribute and use refinementList instead. https://www.vingruppen.no/produkter

All 8 comments

Hi, what would it take to hide price ranges without results, or what makes it impossible?
Ranges without results makes it possible to well, get no results thus hiding all filters.
One solution is to use the currentRefinedValues widget, but I would prefer not to, and to me it feels a little confusing.

Hi, what would it take to hide price ranges without results, or what makes it impossible?

This is doable, by comparing the price stats from the API to the generated price list and hide the non relevant ones.

It would require changes in the price range widget still.

Hi, I'm having the same issue with the numericRefinementList widget I use to let the user select a price range.
As the ranges are displayed even if I have no results in them, it creates some conflicts with the other filters if I select an empty one.
I know I can have the values like that, thanks to the helper

_helper.on('result', function(result) {
    var facetValues = result.getFacetValues('price_usd', {sortBy: ['count:asc']});
});

and it give me that:

capture d ecran 2016-12-22 a 15 56 41

Does it mean that my only solution to hide the non relevant ranges is to check the count of every object in facetValues?
It seems to be a quite heavy procedure if I have a lot of hits.

Any ideas of a better solution?
@spoeken , did you find a satisfying way to do it?

Hi @beHappyBeLindy. Unfortunately even when using getFacetValues you won't be able to retrieve all the facet values (the engine has an hard limit at 1000).

@beHappyBeLindy I ended up with adding a from-to price_range attribute and use refinementList instead. https://www.vingruppen.no/produkter

Ok, thanks.
So, is there another option to hide the empty ranges or at least have the matching result count on each range?

@spoeken, just saw your answer, thanks, I'm gonna try this way.
:)

@spoeken solution is the only solution unless the engine gives us some information about the distribution of the numeric values.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthonyBertrant picture anthonyBertrant  路  3Comments

francoischalifour picture francoischalifour  路  3Comments

zackify picture zackify  路  4Comments

devwax picture devwax  路  3Comments

stianmartinsen picture stianmartinsen  路  3Comments