Filter by numeric attribute


in advance thank you for your help.

I have items with quantity attribute and I would only results whose quantity is greater than zero.

So, with documentation, i make :

    $index->search($id_category, [
        'filters' => 'quantity>0'

I have no results.

My object :

  "id_product": "999",
  "name": "White Tshirt",
  "subtitle": "T-shirt homme blanc",
  "description_short": "Le t-shirt 100% coton des vendredis qui chantent...",
  "quantity": "12",
  "rayon": "HOMME",
  "active": "1",
  "price": {
    "price_ht": 54.166667,
    "price_ttc": 65
  "objectID": "999"

Thanks for your help.

Hi Mikael,

Thank you for reaching out.

At first glance, it seems like the quantity attribute in your object is a string. If this is the case, a numeric filter will not work, it will only work on numbers. Could you try to convert the attribute to a number and check again if it works?

Thank you!

1 Like

I’m really stupid … Thank’s a lot !