1

I have around 2557378 records in ALGOLIA. i am trying to apply few conditions with numericFilters

enter image description here

I need to fetch all a values b values and c values

enter image description here

I used Filter condition as below:

{
    "numericFilters": [
        "A>50 OR B > 0  OR C > 0"
    ]
}

The results for each part showed in below:

enter image description here

The OR condition not work fine. What can be the issue?

Already posted in algolia community : https://discourse.algolia.com/t/numeric-filters/17350?u=thamira.weerakoon

Note: I am not expect A and B and C as below

enter image description here

Summery:

I need to fetch all A value B values and C values via react InstantSearch

wthamira
  • 2,032
  • 2
  • 21
  • 40
  • 1
    In your combined condition you're looking for `A > 0 OR B > 50`, but individually you are checking `A > 50` and `B > 0`, which I believe is a typo – Hao Wu Jan 27 '23 at 07:45
  • AND condition not fulfill this – wthamira Jan 27 '23 at 07:49
  • 1
    The condition should be `C > 0 OR B > 0 OR A > 50`, you swapped the condition between `A` and `B` by accident – Hao Wu Jan 27 '23 at 07:53
  • @HaoWu I don't get you. can you elaborate it. My undemanding is C > 0 OR B > 0 OR A > 50 or A > 0 OR B > 0 OR C > 50 need to return same count – wthamira Jan 27 '23 at 08:09
  • 1
    I'm not sure how your data look like but those are completly different conditions. Normally `A > 50 OR B > 0` = `B > 0 OR A > 50`, but `A > 0 OR B > 50` ≠ `A > 50 OR B > 0` – Hao Wu Jan 27 '23 at 08:12
  • @HaoWu Thank you. I got the point. yes that us typo issue – wthamira Jan 27 '23 at 09:11
  • can you also try `numericFilters: [ [ "A>50", "B > 0", "C > 0"] ]` – cmgchess Jan 28 '23 at 05:51
  • btw are you not getting results that are A>50 only with your current filter? – cmgchess Jan 30 '23 at 17:57

1 Answers1

1

From what I read from the usage notes on numericFilters

  • No boolean operators: you can’t use boolean operators like AND and OR.
  • Multiple filters: if you specify multiple filters, they’re interpreted as a conjunction (AND). If you want to use a disjunction (OR), use a nested array.

you may have to try the array notation mentioned here.

i.e you may have to use it like

{
    numericFilters: [[ "A>50", "B>0",  "C>0"]]
}

I tested with the OR conditions on a dummy index I created and it seems to short circuit after the first OR condition for example "A>50 OR B>0 OR C>0" gave me the hits with A>50 only and changing the order to something like "C>0 OR A>50 OR B>0" gave me C>0 only

cmgchess
  • 7,996
  • 37
  • 44
  • 62