1
0
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:
Silvio Giebl 2020-01-03 22:44:04 +01:00
parent b13b44f18b
commit e2e01effa6

View File

@ -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');