#community-help

Querying Typesense API with Boolean Operators

TLDR JOCSELINE asked about boolean operators in Typesense API's search feature. Jason clarified that Typesense doesn't support boolean operators in the 'q' parameter and suggested a solution. JOCSELINE confirmed the solution worked.

Powered by Struct AI

1

5
2mo
Solved
Join the chat
Sep 25, 2023 (2 months ago)
JOCSELINE
Photo of md5-6abd2f98e57f27b15f1076e22127bfbf
JOCSELINE
09:50 PM
Hi everyone, I have been working with typesense, everything has been amazing! But some days ago I have been implementing the search API that you offers with "&" operator, but there is a problema when I send for example {"USA" & "Technology" & "Jocselyn"} the response comes with "USA" and "Technology" but "Jocselyn" does not appear in the result, in that case, shouldn't the answer be empty? - because the "&" is not true in all cases. I already look in your GitHub and found that it was an error that you already had on the radar, but the comment is from 3 years ago... So my question here is : is that still an error? or is it already fixed? if it is already fixed, can you please help me with some documentation?

PD:
This is the issue I was referring to: https://github.com/typesense/typesense/issues/172

Thanks a lot in advanced.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:52 PM
Typesense does not support boolean operators in the q parameter. Only the filter_by parameter supports boolean operators.

But for doing the equivalent of "USA" & "Technology" & "Jocselyn", you want to set:

typo_tokens_threshold=0
drop_tokens_threshold=0
prefix=false
09:53
Jason
09:53 PM
and then Typesense will only return results if all keywords are present in a single record
JOCSELINE
Photo of md5-6abd2f98e57f27b15f1076e22127bfbf
JOCSELINE
10:01 PM
Thanks for for helping me with error! It's already working.

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:36 PM
Thank you for updating the issue with this solution!