#community-help

Query Order Impact on Number of Results

TLDR Maciej noticed a change in results when swapping query order. Kishore Nallan explained typesense drops tokens until results are found and achieving a "give me documents having any tokens" behavior isn't possible.

Powered by Struct AI
May 08, 2023 (7 months ago)
Maciej
Photo of md5-12131237489cf2e07cd909273ee2adbd
Maciej
11:43 AM
Hey guys, I'm observing some behaviour that I don't really understand. I'm sending query like this: q=cycling running enduro cyclocross road&query_by=categories . In addition I am sending prefix=false. Categories is an array of strings. It would make sense to me that order within query does not matter but if I swap cycling with running I will get different number of results. What am I missing here?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:45 AM
If all tokens in the query are not found in any document typesense tries dropping tokens in the query until results are found. So order matters.
Maciej
Photo of md5-12131237489cf2e07cd909273ee2adbd
Maciej
11:47 AM
I see, so it drops first token and stops when any result is found?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:48 AM
Right to left and then left to right. Stops when results satisfy drop tokens threshold parameter
Maciej
Photo of md5-12131237489cf2e07cd909273ee2adbd
Maciej
11:51 AM
is there a way to achieve give me documents having any of the tokens behaviour?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:39 PM
No that's not possible.