#community-help

Search Query Issues in Typesense

TLDR Gines wanted search results in Typesense for partial matches, not just exact ones. Kishore Nallan suggested solutions, but none fulfilled Gines's requirements.

Powered by Struct AI

1

Oct 17, 2022 (12 months ago)
Gines
Photo of md5-7d463c0d7894ed9aa348f9842f6bc7b5
Gines
08:57 AM
Hi, I am having a problem with my queries.

What I need to do with typesense is to search for all the results that contain some of the words... For example:

I am searching for "red electric car" and typesense only returns results that contains these three words, but I would like it to return results for "red car" and "electric car" as well, is that possible?

Thank you!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:00 AM
Maybe try with exhaustive_search: true ? But it will be a much more expensive query to run.
Gines
Photo of md5-7d463c0d7894ed9aa348f9842f6bc7b5
Gines
09:06 AM
I try it, but same results...

I have these parameters:

            'query_by' => "Name,Description",
            'q' => "red electric car",
            'per_page' => 20,
            'page' => 1,
            'exhaustive_search' => true,
            'prioritize_exact_match' => true,
            'max_candidates' => 1000
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:08 AM
We don't have a mode to do a mandatory OR of the search keywords. So I am trying to see if there is a work around here.... Can you try sending drop_tokens_threshold: 10000 ? This will force Typesense to keep dropping tokens from the query until 10000 results are found and will indirectly result in individual tokens being queried.
Gines
Photo of md5-7d463c0d7894ed9aa348f9842f6bc7b5
Gines
09:18 AM
Now returns many results, but does not prioritize the exact match as expected, and only matches the first word, in this case is returning many "red" hits
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:19 AM
Yeah we don't have a way to do exactly what you want here.

1