Return distinct list of attribute values (for example, list of colors)


I’m new to Algolia, so I’m trying to figure out what is the proper way to return a list of possible filters values.

For example:

Say I have 4 possible colors - yellow, black, red and blue - shirts on my inventory, but by the moment I don’t have the variant blue available on Stock. That said, I would like to offer the user the possibility to filter by yellow, black and red (the ones that I have available in the result by now), but I don’t want to offer then the possibility to filter by blue since I don’t have one by the moment. Given that, is that possible to return a distinct list of attribute values (color list) from a search result to be used as a filter?

PS: Note that it would still be combined with the search query. I.e, say the user search for “Skirts” and it results 10 skirts, but only yellow and red ones in the result. So in that case, I would like to have a list containing only yellow and red on the list, so I can offer the user the possibility to improve the search results by giving them the option to re-filter again by yellow “Skirts” only.

Thank you very much.

Hi @paulo,

You described very accurately the Faceting feature which comes out of the box with Algolia :slight_smile:

If you want to implement it in your frontend experience, you might be interested in the RefinementList widget that is included in the Instansearch library (available for different JS frameworks as well as native mobile).

Hope this helps!

Indeed it was the way to go. Thanks.