Searching for products that have a price range

Hello everyone,

Is there a way for me to search products that have a price range using InstantSearch. I will give you an example so you can understand more clearly to what I’m trying to achieve. Lets say I have product which has a price range of lets say of $100 - $200. Now if I have a range slider and I set the range slider widget to $150 - $300 I want this product to be shown in the hits. If this is not possible with the range slider I would accept any other alternative.

Thank you for your time.

Hi @codeart,

Thanks for contacting Algolia.

Consider having multiple of the same product where each variation has the different price, see a (simplified) example might be:

{
    "name": "product A",
    "product_id": 12345,
    "price": 150
}
{
    "name": "product A",
    "product_id": 12345,
    "price": 200
}
{
    "name": "product A",
    "product_id": 12345,
    "price": 300
}

Then:

Let us know how this helps you!

Hi @ajay.david,

Ok this is an interesting solution, but it won’t cover for example me searching a range of 250-275 unless I index the product for example like 150 times for each of its variation in the price range. It doesn’t have to be with the rangeSlider widget in particular maybe there is a way I can send a custom query to Algolia using InstantSearch?

Thank you for your time.

Hi @codeart,

Indeed, here are two other options:

Option 2: Using rangeInput

But it would have the same need to have the product indexed many times as multiple objects.

Option 3: Using a new facet
Creating a new facet for example price_ranges and then being able to manually filter on those values. This would still require you to know what ranges you want to include at indexing time:

[{
  "name": "product A",
  "price": 200,
  "price_range": ["150-300", "200-250"]
},
{
  "name": "product B",
  "price": 50,
  "price_range": ["0-100"]
}]

Thank you for all your suggestions @ajay.david .