Hello!
I have list of products.
Each product has fields vendorId=<String>
and hidden=<Boolean>
. I need fetch list, which contains products with
hidden:"false" OR (hidden:"true" AND vendorId:"someSpecificVendorId")
. It means that all not hidden products and all (hidden and not hidden) products of specific vendor.
I know, that Algolia doesn’t allow such conditions, like "x OR ( y AND z) OR ( a AND b)"
and it means that such combination doesn’t work -
hidden:"false" OR (hidden:"true" AND vendorId:"ApwWrFwz")
Can somebody recommend me some solution? I can specify all vendors, if it’s necessary. It’s not too long list.
I’m using algoliasearch
with vue.js.
Thank you!
Hi,
First things first, know that we have a nice filters validator embedded in our documentation here: https://www.algolia.com/doc/api-reference/api-parameters/filters/#filters-syntax-validator
In your specific example, you could write:
hidden:"false" OR vendorId:"someSpecificVendorId"
More generally speaking, when you are hitting this limitation, the way to get around is to create a new attribute projecting the nested “AND” condition.
For example you could introduce a new boolean attribute on your record called “always_visible” and pre-compute whatever you need such that you can then do hidden:"false" OR always_visible:"true"
.
Best,