@@ -35,7 +35,11 @@ func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error {
35
35
})
36
36
}
37
37
38
- const maxBatchSize = 16
38
+ const (
39
+ maxBatchSize = 16
40
+ // fuzzyDenominator determines the levenshtein distance per each character of a keyword
41
+ fuzzyDenominator = 4
42
+ )
39
43
40
44
// IndexerData an update to the issue indexer
41
45
type IndexerData internal.IndexerData
@@ -156,19 +160,16 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
156
160
var queries []query.Query
157
161
158
162
if options .Keyword != "" {
163
+ fuzziness := 0
159
164
if options .IsFuzzyKeyword {
160
- queries = append (queries , bleve .NewDisjunctionQuery ([]query.Query {
161
- inner_bleve .MatchPhraseQuery (options .Keyword , "title" , issueIndexerAnalyzer ),
162
- inner_bleve .MatchPhraseQuery (options .Keyword , "content" , issueIndexerAnalyzer ),
163
- inner_bleve .MatchPhraseQuery (options .Keyword , "comments" , issueIndexerAnalyzer ),
164
- }... ))
165
- } else {
166
- queries = append (queries , bleve .NewDisjunctionQuery ([]query.Query {
167
- inner_bleve .PrefixQuery (options .Keyword , "title" ),
168
- inner_bleve .PrefixQuery (options .Keyword , "content" ),
169
- inner_bleve .PrefixQuery (options .Keyword , "comments" ),
170
- }... ))
165
+ fuzziness = len (options .Keyword ) / fuzzyDenominator
171
166
}
167
+
168
+ queries = append (queries , bleve .NewDisjunctionQuery ([]query.Query {
169
+ inner_bleve .MatchPhraseQuery (options .Keyword , "title" , issueIndexerAnalyzer , fuzziness ),
170
+ inner_bleve .MatchPhraseQuery (options .Keyword , "content" , issueIndexerAnalyzer , fuzziness ),
171
+ inner_bleve .MatchPhraseQuery (options .Keyword , "comments" , issueIndexerAnalyzer , fuzziness ),
172
+ }... ))
172
173
}
173
174
174
175
if len (options .RepoIDs ) > 0 || options .AllPublic {
0 commit comments