1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

All: Improved support for Japanese, Chinese, Korean search queries (also applies to Goto Anything)

This commit is contained in:
Laurent Cozic
2019-04-03 07:46:41 +01:00
parent 252d937405
commit 72b36522e8
4 changed files with 44 additions and 10 deletions

View File

@@ -344,17 +344,18 @@ class SearchEngine {
}
async basicSearch(query) {
let p = query.split(' ');
let temp = [];
for (let i = 0; i < p.length; i++) {
let t = p[i].trim();
if (!t) continue;
temp.push(t);
query = query.replace(/\*/, '');
const parsedQuery = this.parseQuery(query);
const searchOptions = {};
for (const key of parsedQuery.keys) {
const term = parsedQuery.terms[key][0].value;
if (key === '_') searchOptions.anywherePattern = '*' + term + '*';
if (key === 'title') searchOptions.titlePattern = '*' + term + '*';
if (key === 'body') searchOptions.bodyPattern = '*' + term + '*';
}
return await Note.previews(null, {
anywherePattern: '*' + temp.join('*') + '*',
});
return Note.previews(null, searchOptions);
}
async search(query) {