#community-help

Using Typesense to Retrieve Multiple Keyword Matches

TLDR Ravi expressed confusion over Typesense not returning all results for multi-keyword queries. Kishore Nallan explained that Typesense does AND of all keywords and drops tokens from right to left until records are found if no exact match exists. Kishore Nallan clarified that disabling the drop_tokens_threshold could alter this behavior.

Powered by Struct AI

1

Apr 07, 2022 (21 months ago)
Ravi
Photo of md5-c3392b6b3247c0691a80ddbb516728c1
Ravi
11:15 AM
Is it possible to search by different words? I have brand collection with names “dettol” and “moove”. If i search for “dettol” or “moov”, i am getting proper results. But when I search for both brands togather “dettol moove”, only “dettol” is being returned. Is it possible to get both the brands in results here?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:21 AM
If Typesense does not find records with all tokens in the query it will drop tokens from the query right to left and then left to right until records are found.
11:21
Kishore Nallan
11:21 AM
If you are talking about filtering, see the example Anton posted after this message on the channel to do a OR filter.
Ravi
Photo of md5-c3392b6b3247c0691a80ddbb516728c1
Ravi
11:31 AM
Slight misunderstanding i think. I have collection of products {name: “Soap”, brand: “dettol”}, {name: “Shampoo”, brand: “clinc plus”}. In this case if i search with “dettol clinic”, will it return both products?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:33 AM
No, Typesense does AND of all keywords in the query. If it cannot find any document containing all words in the query, like in this case, instead of doing a OR, it drops tokens from the query one by one until results are found.
Ravi
Photo of md5-c3392b6b3247c0691a80ddbb516728c1
Ravi
11:56 AM
Okay
Apr 08, 2022 (21 months ago)
Robert
Photo of md5-6384d24e1825271b2c37ad8afa24a899
Robert
02:50 AM
Any way to disable that dropping behavior? To only return results if all keywords were found?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:50 AM
Yes set drop_tokens_threshold to zero.

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads