Faceting for min/max pairs


we do have a lot of facets that are min/max value pairs. Think of min/max operating preasures, min/max length for expandable stuff etc. I’m trying to get my head around what the best approach to those is.
I could have two attributes each, obviously. This is trivial but not nice for the user. Anyone got a good example how to handle that?


Hello Alex,

I’m not sure I understand the use-case, I’m not very familiar with what you refer as min/max. Would you be able to share a bit more context? Maybe the ideal UI you would have in mind and we can see the best way to format the data with Algolia.


Actually I’m still unsure how the UI should be, that might be part of the problem.

I give an example:
I just bought a desk that is adjustable in height. as such, it has a minimum and a maximum height.
Same thing for an adjustable lamp that hangs from the ceiling.
Or if I buy some pumping equiptment, this has a maximum and a minimum preassure.

Oh I see. Then in that case maybe you could create two values: min and max in your record, and define both as attributesForFacetting.

Taking the example of your desk, you might want to let your users define the ideal height of the desk. Maybe they want a desk that is 150cm tall. You could then provide them with a UI widget for them to enter this height (it can be as simple as an input, or you can get fancy with some kind of slider, or predefined values). Then, once the ideal height is selected, you send a query to Algolia by specifying min < ${ideal_height} AND max > ${ideal_height} in the filters.

In the end, it all depends of your use-case and the UI you’d like to present to the user. That’s why in InstantSearch we went with a UI-first approach: we want you to think about the best UX you can provide to your users, and then we’ll build the widget that will transform this into Algolia parameters.

Hope that helps :slight_smile:

UI first is what I’m trying to solve :wink:
I like the idea of having the user select a value, and than transform that into a query with two sides (min&max). Any idea how to get that done in magento? Indexing the values is obvious, but how do I transform the query accordingly.
Also, in an ideal world, I’d have an option for the user to switch to more detailed searching, i.e. seperating the one slides into a control that can search independently for min and max.I guess that should be doable by undoing(unhiding whatever the magic code for the first option did…

I’m no expert of Magento so can’t be 100% sure of the best way to do it there, but if you can edit your front-end templates, you should be able to add new InstantSearch widgets there. Let me know if it sounds too obscure and I’ll invoke one of our Magento experts to this thread :slight_smile:

As for the UI, we do not have a single slider widget (yet) in the InstantSearch library (we only have a range slider, with two handles). What we do have though is a widget to select into a list of predefined ranges. Maybe that’s something you could use for the “simple” default display. We have a few other widgets that might also interest you.

Then, you could add an “advanced filtering” button that would hide this widget and show two other custom widgets in its place, one for the min value and another for the max values. Those widgets you’ll have to create yourself (you can check the documentation on custom widgets). The idea would be to create a widget that is basically an input field linked to either min or max and whenever its value is changed it would update the min/max limit. You can even add a slider mechanism on top of that to make it even more usable on mobile.

Let me know if that helps, or if you’re hitting any specific wall while implementing it. That’s a pretty interesting use-case.