AND groups inside OR

We need to display all Shopify products that

1 are either not tracked by Shopify ( NOT inventory_management:shopify) or
2 if it is tracked by Shopify has an inventory level larger than 0. (inventory_management:shopify AND inventory_quantity > 0)

This is our current filter for it:

‘(NOT inventory_management:shopify) OR (inventory_management:shopify AND inventory_quantity > 0)’

The fitler is not displaying any results at all, I guess it is because of the limitation on using AND groups inside OR statements.

Is there any workarounds for this or can we simply not use this type of logic with Algolia.

This could work: NOT inventory_management:shopify OR inventory_quantity > 0.
Indeed, the not is actually already saying everything else than inventory_management:shopify , so you don’t have to repeat it afterwards.

Hi Jerska, thanks a lot for your reply, I truly appreciate it.

I realized that it was duplicating that part after I posted, sorry for that. But I tested your suggestion and I did not get that to work either. Both statements works well separately but not when you combine them with the OR operator. Is this because the OR operator can’t mix categories, string and number?

Oh, this is painful, you’re correct.
I’ll work on adding a number to represent the inventory_management.

Can you ping me again tomorrow if I haven’t updated you?

That sounds great, thanks a lot for doing that! I’ll ping ping you tomorrow.

Hi Jerska, I just want to check if you have had time create an update for this?

I’ve just pushed the change with a new inventory_management_shopify to 1 if true and 0 if false.
You’ll need to run a reindex to have this attribute populated on your records.

See .

1 Like

It works very well, thanks a lot for creating a solution for this so quickly, very appreciated!.

1 Like