feat(full-text-search): enable forward for ascii text

This commit is contained in:
Tienson Qin
2021-02-14 13:49:55 +08:00
parent 4dbdd3978c
commit 1e4fdc5508

View File

@@ -206,5 +206,19 @@ export const win32 = path => {
};
export const searchTokenize = str => {
return str.split(/\W+/).concat(str.replace(/[\x00-\x7F]/g, '').split('')).filter(e => !!e);
let ascii_words = str.split(/\W+/);
let non_ascii_str = str.replace(/[\x00-\x7F]/g, '');
if (non_ascii_str == '') {
// forward
const length = str.length;
let token = '';
let tokens = [];
for(let a = 0; a < length; a++){
token += str[a];
tokens.push(token);
};
return tokens;
} else {
return ascii_words.concat(non_ascii_str.split('')).filter(e => !!e);
}
};