If you search for the string texbytopi, you would expect that texdoc would open the documentation for the package texbytopic, but instead it tells you that there are no good matches:
$ texdoc -Ml texbytopi
texdoc warning: No good result found, showing all results.
texbytopi -8.5 /usr/local/texlive/2022/texmf-dist/doc/plain/texbytopic/TeXbyTopic.pdf The book itself
texbytopi -9.8 /usr/local/texlive/2022/texmf-dist/doc/plain/texbytopic/README Readme
But if you mistype any letter, then texdoc counter-intuitively gives a better score and automatically opens the document:
$ texdoc -Ml texbytopz
texbytopz 7.0 /usr/local/texlive/2022/texmf-dist/doc/plain/texbytopic/TeXbyTopic.pdf The book itself
texbytopz 1.8 /usr/local/texlive/2022/texmf-dist/doc/plain/texbytopic/README Readme
The fuzzy search I introduced in Texdoc v3.0 is incomplete. The fuzzy search is only executed when Texdoc fails to find anything in the standard search; in the second case, the fuzzy search is not working because something was found even though only negative matches were found. This is why the results are worse than in the third case (texdoc -lM zezbytopiz).
The fuzzy search should be triggered even when only bad results are found. More to the point, you could always use fuzzy search in any case and, as you say, give an appropriate penalty based on edit distance. However, the latter would require more drastic changes than the former.
If you search for the string
texbytopi
, you would expect that texdoc would open the documentation for the packagetexbytopic
, but instead it tells you that there are no good matches:But if you mistype any letter, then texdoc counter-intuitively gives a better score and automatically opens the document:
This is unexpected. @wtsnjp suggests the cause of this in https://github.com/TeX-Live/texdoc/issues/98#issuecomment-1445345710: