mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-17 18:44:45 +02:00
Desktop: Keep search fuzzy scores between 0 and 2 (#3812)
This commit is contained in:
parent
a7fa119041
commit
12c0a05af0
@ -460,6 +460,15 @@ class SearchEngine {
|
||||
const fuzzyTitle = await this.fuzzifier(titleTerms.filter(x => !x.wildcard).map(x => trimQuotes(x.value)));
|
||||
const fuzzyBody = await this.fuzzifier(bodyTerms.filter(x => !x.wildcard).map(x => trimQuotes(x.value)));
|
||||
|
||||
// Floor the fuzzy scores to 0, 1 and 2.
|
||||
const floorFuzzyScore = (matches) => {
|
||||
for (let i = 0; i < matches.length; i++) matches[i].score = i;
|
||||
};
|
||||
|
||||
fuzzyText.forEach(floorFuzzyScore);
|
||||
fuzzyTitle.forEach(floorFuzzyScore);
|
||||
fuzzyBody.forEach(floorFuzzyScore);
|
||||
|
||||
const phraseTextSearch = textTerms.filter(x => x.quoted);
|
||||
const wildCardSearch = textTerms.concat(titleTerms).concat(bodyTerms).filter(x => x.wildcard);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user