A name's match quality against needle: the diacritic-folded
comparison decides which tier it reaches (0 for no match, otherwise
QUALITY_SUBSTRING/QUALITY_WHOLE_WORD/QUALITY_EXACT), and the raw
(unfolded) comparison decides whether EXACT_SPELLING_BONUS applies --
it does whenever the raw comparison reaches at least the same tier,
which folding can only ever match or improve on for the same
name/needle pair (never make worse), so "reaches at least" is exactly
"didn't need folding to get here".
Only a substring match counts at all, so sorting ranks the same set
unsorted search finds: without that, " di " would match "Di" by its
tokens alone, and a search index (which only guarantees folded
substring candidates, Appendix B.9) would miss it.
A name's match quality against
needle: the diacritic-folded comparison decides which tier it reaches (0 for no match, otherwiseQUALITY_SUBSTRING/QUALITY_WHOLE_WORD/QUALITY_EXACT), and the raw (unfolded) comparison decides whetherEXACT_SPELLING_BONUSapplies -- it does whenever the raw comparison reaches at least the same tier, which folding can only ever match or improve on for the same name/needle pair (never make worse), so "reaches at least" is exactly "didn't need folding to get here".Only a substring match counts at all, so sorting ranks the same set unsorted search finds: without that, " di " would match "Di" by its tokens alone, and a search index (which only guarantees folded substring candidates, Appendix B.9) would miss it.