mirror of
https://github.com/thangisme/notes.git
synced 2025-02-01 18:16:25 -05:00
Add fuzzy search if no results were found
This commit is contained in:
parent
b13b44f18b
commit
e2e01effa6
@ -154,6 +154,15 @@ 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))
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (results.length == 0) {
|
||||
var noResultsDiv = document.createElement('div');
|
||||
noResultsDiv.classList.add('search-no-result');
|
||||
|
Loading…
Reference in New Issue
Block a user