Skip to content

Commit 7791971

Browse files
committed
Included documentation about fuzziness' semantics within Bleve
1 parent 0de61a1 commit 7791971

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

modules/indexer/internal/bleve/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func openIndexer(path string, latestVersion int) (bleve.Index, int, error) {
5353
return index, 0, nil
5454
}
5555

56+
// This method test the GuessFuzzinessByKeyword method. The fuzziness is based on the levenshtein distance and determines how many chars
57+
// may be different on two string and they still be considered equivalent.
58+
// Given a phrasse, its shortest word determines its fuzziness. If a phrase uses CJK (eg: `갃갃갃` `啊啊啊`), the fuzziness is zero.
5659
func GuessFuzzinessByKeyword(s string) int {
5760
tokenizer := unicode.NewUnicodeTokenizer()
5861
tokens := tokenizer.Tokenize([]byte(s))

modules/indexer/internal/bleve/util_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13-
func TestBleveIndexAndSearch(t *testing.T) {
13+
func TestBleveGuessFuzzinessByKeyword(t *testing.T) {
1414
scenarios := []struct {
1515
Input string
16-
Fuzziness int
16+
Fuzziness int // See util.go for the definition of fuzziness in this particular context
1717
}{
1818
{
1919
Input: "",

0 commit comments

Comments
 (0)