#community-help

Adding OR Statement in filter_by of apiKey scope

TLDR Danny asks about adding an OR statement to filter values in two fields. Jason informs that Typesense doesn't yet support it but suggests splitting the query across a multi_search request.

Powered by Struct AI
+11
7
14mo
Solved
Join the chat
Jul 14, 2022 (14 months ago)
Danny
Photo of md5-7cbfa86cff2f773b5dcbeba890c1227a
Danny
08:18 PM
hello i am making a filter_by in my apiKey scope but i have to add an OR statement to that filter_by how should i do it?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:31 PM
Danny Is it an OR of values in a single field or across fields?
Danny
Photo of md5-7cbfa86cff2f773b5dcbeba890c1227a
Danny
08:34 PM
I want to filter by a value that can be in two fields of the same document for example personId can be in array1 or in array2
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:35 PM
Typesense doesn't support ORs across multiple fields unfortunately, we plan to add it in the near future though
08:35
Jason
08:35 PM
So you would have to split the query across two searches in a multi_search request
08:35
Jason
08:35 PM
and use two separate x-typesense-api-key parameters in each search (as of v0.23.1), with just one condition per scoped api key / search
Danny
Photo of md5-7cbfa86cff2f773b5dcbeba890c1227a
Danny
08:37 PM
ok I will try that thank you very much
+11