#community-help

Query Parameter Not Matching Full Names

TLDR Oliver experienced issues with query parameters not matching full names. Jason suggested adjusting the drop_tokens_threshold and max_candidates settings, while linking to a feature request to track demand.

Powered by Struct AI
6
7mo
Solved
Join the chat
Mar 09, 2023 (7 months ago)
Oliver
Photo of md5-d8ab318faff4aecf0aa4f67525bd590d
Oliver
04:19 PM
Hi team 👋:skin-tone-2:, I wanted to ask:
I have a query parameter as Chris Schmidt , and I’m querying by first name, last name. However I’m getting results matched just by Chris, and no matches by the lastName, so for example I would get Chris Rogers, Chris Williams etc above Christopher Schmidt, I believe this is because it’s taking it as a whole sentence instead of per word, so my question is
How could I get matches both by Chris and Schmidt 🙌:skin-tone-2:
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:42 PM
This behavior is because Typesense first searches for Chris Schmidt and when it doesn’t find a full exact match, it then tries to drop words from the query (configured by drop_tokens_threshold) and searches just Chris and Schmidt.

If you’ve configured first_name to have higher priority (based on order of fields in query_by) it then finds an exact match for Chris and prioritizes those records first in the results.
04:42
Jason
04:42 PM
Also, for shortened version of names specifically, here’s a way to handle those: https://typesense-community.slack.com/archives/C01P749MET0/p1677788106005749
04:43
Jason
04:43 PM
Could you add your example as a comment to this feature request so we can track demand?
Mar 10, 2023 (7 months ago)
Oliver
Photo of md5-d8ab318faff4aecf0aa4f67525bd590d
Oliver
03:58 PM
Jason Thanks for your quick reply. I understand your explanation, however, even if I set the weights the same & set prioritize exact match to false, it would not take into account Schmidt & return the results for Chris. Do you think there’s a workaround to also take into account the second word when dropping words?

Thanks added this to the Feature request, it would be awesome 🙌:skin-tone-2:
Mar 11, 2023 (7 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:12 AM
Could you try increasing drop_tokens_treshold: 1000 and set max_candidates: 1000 to see if that helps?