Hi, It seems I misunderstand typo tolerance settin...
# community-help
g
Hi, It seems I misunderstand typo tolerance settings. I have 2 documents with: doc1 name: "Linder" doc 2 name: "Lindenhof" Here is the search query I'm doing
Copy code
"limit_hits": 6,
"num_typos": 1,
"per_page": 6,
"q": "Linder",
"query_by": "name",
"typo_tokens_threshold": 1
Only one document is returned: the document 1. The document 2 is not returned. If one typo is allowed with "num_typos", why I'm not getting both document returned? Thanks
k
@gab gab It's because of
"typo_tokens_threshold": 1
-> this means that you want Typesense to continue searching with more and more typos until atleast
1
document is found. In this case, since
Lindenhof
is a zero-typo prefix match, that requirement is satisfied and typo relaxation is not done. If you increased
typo_tokens_threshold
to 2, the other result will show up.
g
Wow I'm so sorry I just noticed because of your answer my isssue in the question. I just fix the "q" param. My issue is with
"q": "Linder"
param.
👍 1
@Kishore Nallan I don't get it, isn't it an issue ? Shoudn't "num_typos" cover this case ?
k
Num typos is the maximum number of typos you want to account for, but it is subject to typo tokens threshold. Some wanted no typo results to be shown if there exists documents without typo so we had to introduce the threshold parameter to handle that.
By default, typo tokens threshold is 1. Which means that if atleast one document exists which matches with query tokens without any typos, then don't look for other documents with typo matches. If you want typo matches also, then just increase this number to 10 or something.
g
Ah ok I get it, I thought num_typos was applied and then, results was enlarged with the typo tokens threshold. But now, how can I say strictly one typo is allowed + allow typo and no typo ?
k
Set num_typos: 1 and set typo tokens threshold to a large enough number that's likely to produce enough results.
g
num_typo will still be the maximum typo allowed?
k
Yes, that's what you want right?
g
yep exactly. I thought in that situation.
Copy code
num_typo:1
typo_tokens_threshold : 10
typo_tokens_threshold would try to allow more typo error until 10 is reached. So just to be sure, it means in the upper case, if I have only one document with 0 or 1 typo, and 100 other documents with 5 typos. I will get only one result?
k
Yes. Num typos is a max typos that will never be breached. The typo tokens threshold will still respect that.
g
Ok, thanks for this clarification 🙂 !
👍 1