mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
@@ -47,3 +47,15 @@ func openIndexer(path string, latestVersion int) (bleve.Index, int, error) {
|
||||
|
||||
return index, 0, nil
|
||||
}
|
||||
|
||||
func GuessFuzzinessByKeyword(s string) int {
|
||||
// according to https://github.com/blevesearch/bleve/issues/1563, the supported max fuzziness is 2
|
||||
// magic number 4 was chosen to determine the levenshtein distance per each character of a keyword
|
||||
// BUT, when using CJK (eg: `갃갃갃` `啊啊啊`), it mismatches a lot.
|
||||
for _, r := range s {
|
||||
if r >= 128 {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
return min(2, len(s)/4)
|
||||
}
|
||||
|
Reference in New Issue
Block a user