#community-help

"Query By" Parameters Resulting in Fewer Search Results

TLDR Jon encountered unexpected behavior with "query by" parameters. Upon checking the post request body by Jason, Kishore Nallan noted the issue originates from the typo match with "full stack". Suggested solution was setting split_joins_tokens: always.

Powered by Struct AI

3

9
15mo
Solved
Join the chat
Jul 29, 2022 (15 months ago)
Jon
Photo of md5-9d01f9f3c352222b5a7902d087745dc3
Jon
05:45 PM
Hello! I am seeing some strange behavior with Query By parameters. I would expect that adding a new parameter would either not affect search results, or would increase the number of results. But when I add a parameter, I’m actually seeing fewer results. Can you help me understand why?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:49 PM
Hmmm, that sounds like a bug.

Could you open up the browser dev console, then repeat the same search again and then copy as curl the request sent to the .../api/... endpoint, and then paste just the post request body here which has all the search params?
Jon
Photo of md5-9d01f9f3c352222b5a7902d087745dc3
Jon
05:50 PM
sure
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:52 PM
Just needed this:

--data-raw '{"searches":[{"query_by":"title,slug,categories,description,shortDescription","group_by":"","sort_by":"_text_match:desc","highlight_full_fields":"title,slug,categories,description,shortDescription","collection":"catalogContent_20220729T163000","q":"full stack","facet_by":"","page":1,"per_page":5}]}' \
  --compressed

Could you delete the rest of your message, since it contains auth and session information
Jon
Photo of md5-9d01f9f3c352222b5a7902d087745dc3
Jon
05:52 PM
I’ve deleted the message, thanks

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:53 PM
Will take a look and keep you posted later this evening
Jon
Photo of md5-9d01f9f3c352222b5a7902d087745dc3
Jon
05:53 PM
Thanks. Rebecca Doug FYI

2

Jul 30, 2022 (15 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:33 AM
Initially, there's no match for "full stack" query so "treat space as typo" behavior kicks in, and "fullstack" is tried as a fallback which produces results. When the "shortDescription" field is added, the phrase "full stack" itself produces results with typo match with the words "fully" and "stack" in a record so we stop there (1 typo match).

If you set the split_joins_tokens: always then Typesense will always attempt to look for space as typo variations of the query and this will ensure that same set of results are produced with/without the shortDescription field.
Jon
Photo of md5-9d01f9f3c352222b5a7902d087745dc3
Jon
09:19 PM
got it, thanks. I’m sure we would prefer to not treat spaces as a typo, but this is a good fix for now!