Setting for fuzziness

This commit is contained in:
Simon Cambier
2023-06-22 19:47:00 +02:00
parent be2a724c0c
commit 34ef17b4ed
2 changed files with 46 additions and 4 deletions

View File

@@ -188,12 +188,26 @@ export class Omnisearch {
logDebug('Starting search for', query)
let fuzziness: number
switch (settings.fuzziness) {
case '0':
fuzziness = 0
break
case '1':
fuzziness = 0.1
break
default:
fuzziness = 0.2
break
}
let results = this.minisearch.search(query.segmentsToStr(), {
prefix: term => term.length >= options.prefixLength,
// length <= 3: no fuzziness
// length <= 5: fuzziness of 10%
// length > 5: fuzziness of 20%
fuzzy: term => (term.length <= 3 ? 0 : term.length <= 5 ? 0.1 : 0.2),
fuzzy: term =>
term.length <= 3 ? 0 : term.length <= 5 ? fuzziness / 2 : fuzziness,
combineWith: 'AND',
boost: {
basename: settings.weightBasename,
@@ -216,7 +230,6 @@ export class Omnisearch {
ext.startsWith(e.startsWith('.') ? e : '.' + e)
)
})
console.log(query.query.ext, results.length)
}
// Filter query results that match the path