1
0
mirror of https://github.com/thangisme/notes.git synced 2024-12-22 08:26:34 -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,13 +157,17 @@ function searchLoaded(index, docs) {
});
if ((results.length == 0) && (input.length > 2)) {
var tokens = lunr.tokenizer(input).filter(function(token, i) {
return token.str.length < 20;
})
if (tokens.length > 0) {
results = index.query(function (query) {
var tokens = lunr.tokenizer(input)
query.term(tokens, {
editDistance: Math.round(Math.sqrt(input.length / 2 - 1))
});
});
}
}
if (results.length == 0) {
var noResultsDiv = document.createElement('div');