mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 17:21:23 +08:00
simple custom tokenizer search instead of fuse
This commit is contained in:
parent
a36282caf0
commit
9e5fcb8be2
1 changed files with 40 additions and 1 deletions
|
@ -63,6 +63,45 @@ $.ui.autocomplete.filter = function (array, terms) {
|
|||
]
|
||||
};
|
||||
|
||||
|
||||
const startDate = new Date();
|
||||
|
||||
const fuse = new Fuse(array, options); // "list" is the item array
|
||||
return fuse.search(terms);
|
||||
|
||||
const results = fuse.search(terms);
|
||||
|
||||
console.log("Search took " + (new Date().getTime() - startDate.getTime()) + "ms");
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
$.ui.autocomplete.filter = function (array, terms) {
|
||||
if (!terms) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const startDate = new Date();
|
||||
|
||||
const results = [];
|
||||
const tokens = terms.toLowerCase().split(" ");
|
||||
|
||||
for (const item of array) {
|
||||
let found = true;
|
||||
const lcValue = item.value.toLowerCase();
|
||||
|
||||
for (const token of tokens) {
|
||||
if (lcValue.indexOf(token) === -1) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
results.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Search took " + (new Date().getTime() - startDate.getTime()) + "ms");
|
||||
|
||||
return results;
|
||||
};
|
Loading…
Reference in a new issue