#community-help

Issues with Using the OR Operator in Filter Query

TLDR Mehdi inquired about using OR in a filter query and was told by Kishore Nallan that only AND is supported. Ricardo suggested the use of multisearch and dedup, while Mehdi decided to modify the document's fields.

Powered by Struct AI

1

1

8
29mo
Solved
Join the chat
Jul 07, 2021 (29 months ago)
Mehdi
Photo of md5-a3ecae8c75dfccecfa4e0116c9241a34
Mehdi
09:08 AM
Hello,

Is there a way to pass an or expression to the filter_by argument? Using "||" or "|" returns an Error 400 Could not parse the filter query
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:09 AM
The filter by query supports only basic operators. What query do you want to make?

1

Mehdi
Photo of md5-a3ecae8c75dfccecfa4e0116c9241a34
Mehdi
09:10 AM
For example filter by num_employees:>100 or country:= USA
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:11 AM
We currently support only && so you can do ANDing of conditions on two different fields, but can't do OR.
09:12
Kishore Nallan
09:12 AM
You can do OR within a single field by using a list filter operation, e.g: store_id: [100, 200, 300]
Ricardo
Photo of md5-914a8b39b82fd99b8ecd985427660deb
Ricardo
09:13 AM
multisearch and dedup on the client side, a bit more work involved but should do it.
Mehdi
Photo of md5-a3ecae8c75dfccecfa4e0116c9241a34
Mehdi
09:37 AM
My solution is to add a field to my documents that contains the OR of the fields that i want to filter_by since they're all boolean
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:38 AM
👍 More flexible query operations is on roadmap, so hopefully you won't need it sometime in future 🙂

1