Is it possible to add groups of ANDs within ORs in filtering

As mentioned here Filters and boolean operators | Algolia there is a limitation to using ANDs within ORs for our use case we would like to support ANDs within ORs.

Is it possible from algolia side or any alternative solution will be helpful?

It is possible to use boolean algebra and distribute the values to reverse the operand, for example:

(X AND Y) OR Z

is equivalent to

(X OR Z) AND (Y OR Z)

For complex filtering logics (e.g. permissions) it might be hard to implement and lead to very long and convoluted filter parameters, but it’s also possible to create a transformation function or search Google for a “boolean algebra library” or “boolean expression parser” which might offer this type of conversion out of the box.

Sure, this helps. Thanks

1 Like