1
0
mirror of https://github.com/thangisme/notes.git synced 2024-12-22 13:56:28 -05:00

Fixed fuzzy search hangs for long words

This commit is contained in:
Silvio Giebl 2020-06-13 22:37:39 +02:00
parent da9276121a
commit b7a5458375

View File

@ -157,12 +157,16 @@ function searchLoaded(index, docs) {
}); });
if ((results.length == 0) && (input.length > 2)) { if ((results.length == 0) && (input.length > 2)) {
results = index.query(function (query) { var tokens = lunr.tokenizer(input).filter(function(token, i) {
var tokens = lunr.tokenizer(input) return token.str.length < 20;
query.term(tokens, { })
editDistance: Math.round(Math.sqrt(input.length / 2 - 1)) if (tokens.length > 0) {
results = index.query(function (query) {
query.term(tokens, {
editDistance: Math.round(Math.sqrt(input.length / 2 - 1))
});
}); });
}); }
} }
if (results.length == 0) { if (results.length == 0) {