mirror of
https://github.com/thangisme/notes.git
synced 2024-12-22 08:07:11 -05:00
Fixed fuzzy search hangs for long words
This commit is contained in:
parent
da9276121a
commit
b7a5458375
@ -157,12 +157,16 @@ function searchLoaded(index, docs) {
|
||||
});
|
||||
|
||||
if ((results.length == 0) && (input.length > 2)) {
|
||||
results = index.query(function (query) {
|
||||
var tokens = lunr.tokenizer(input)
|
||||
query.term(tokens, {
|
||||
editDistance: Math.round(Math.sqrt(input.length / 2 - 1))
|
||||
var tokens = lunr.tokenizer(input).filter(function(token, i) {
|
||||
return token.str.length < 20;
|
||||
})
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user