#community-help

Achieving Desired Query Results in Typesense

TLDR Timothy asked how to include documents containing any query term in Typesense. Jason explained that by adjusting the drop_tokens_threshold, this behaviour can be achieved.

Powered by Struct AI

1

4
15mo
Solved
Join the chat
Sep 21, 2022 (15 months ago)
Timothy
Photo of md5-0401a647e8b63e9fb473f4c1686f92be
Timothy
03:01 PM
Given a single collection of documents, and a single query, I would like my results set to include documents that contained any of the query terms. So, for example, if I query "Tesla", "General Motors", "Mercedes" the result set would include any document that contained at least one of my query terms. Is this possible?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:05 PM
This is the default behavior of Typesense - meaning if all keywords are not found in a single record, Typesense then starts dropping keywords until “enough” results are found.

where the value for “Enough” results is controlled by the drop_tokens_threshold parameter. This is documented in the last row of this table: https://typesense.org/docs/0.23.1/api/search.html#typo-tolerance-parameters
03:06
Jason
03:06 PM
So if you set drop_tokens_threshold to a very high value (higher than the total number of records in your dataset), you’ll get the behavior you’re looking for.
Timothy
Photo of md5-0401a647e8b63e9fb473f4c1686f92be
Timothy
05:55 PM
ok, great - thanks for your response and clarifying this for me

1