From 6989f9fd16cf7cfed8fac05c58bb582eaf281448 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 10 Jan 2019 19:25:21 +0000 Subject: [PATCH] CLI: Fixes #1096: Fixed search function in terminal app --- CliClient/app/command-search.js | 1 + ReactNativeClient/lib/BaseApplication.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CliClient/app/command-search.js b/CliClient/app/command-search.js index 3ae14ea2c..f5f524a45 100644 --- a/CliClient/app/command-search.js +++ b/CliClient/app/command-search.js @@ -41,6 +41,7 @@ class Command extends BaseCommand { title: pattern, query_pattern: pattern, query_folder_id: folder ? folder.id : '', + basic_search: true, type_: BaseModel.TYPE_SEARCH, }, }); diff --git a/ReactNativeClient/lib/BaseApplication.js b/ReactNativeClient/lib/BaseApplication.js index 8b9b9a526..8dd82f64d 100644 --- a/ReactNativeClient/lib/BaseApplication.js +++ b/ReactNativeClient/lib/BaseApplication.js @@ -220,7 +220,23 @@ class BaseApplication { notes = await Tag.notes(parentId, options); } else if (parentType === BaseModel.TYPE_SEARCH) { const search = BaseModel.byId(state.searches, parentId); - notes = await SearchEngineUtils.notesForQuery(search.query_pattern); + + if (search.basic_search) { + // NOTE: Copied and pasted from ReactNativeClient/lib/components/screens/search.js + let p = search.query_pattern.split(' '); + let temp = []; + for (let i = 0; i < p.length; i++) { + let t = p[i].trim(); + if (!t) continue; + temp.push(t); + } + + notes = await Note.previews(null, { + anywherePattern: '*' + temp.join('*') + '*', + }); + } else { + notes = await SearchEngineUtils.notesForQuery(search.query_pattern); + } } }