improvements to saved search

This commit is contained in:
zadam
2020-11-30 23:20:12 +01:00
parent 2a6978c349
commit a68c61b2f0
7 changed files with 37 additions and 21 deletions

View File

@@ -46,16 +46,16 @@ async function searchFromNote(req) {
return [400, `Note ${req.params.noteId} is not search note.`]
}
const searchString = note.getLabelValue('searchString');
let searchResultNoteIds;
try {
if (searchString.startsWith('=')) {
const relationName = searchString.substr(1).trim();
const searchScript = note.getRelationValue('searchScript');
const searchString = note.getLabelValue('searchString');
searchResultNoteIds = await searchFromRelation(note, relationName);
} else {
if (searchScript) {
searchResultNoteIds = await searchFromRelation(note, 'searchScript');
}
else if (searchString) {
const searchContext = new SearchContext({
includeNoteContent: note.getLabelValue('includeNoteContent') === 'true',
excludeArchived: true,
@@ -65,6 +65,9 @@ async function searchFromNote(req) {
searchResultNoteIds = searchService.findNotesWithQuery(searchString, searchContext)
.map(sr => sr.noteId);
}
else {
searchResultNoteIds = [];
}
}
catch (e) {
log.error(`Search failed for note ${note.noteId}: ` + e.message + ": " + e.stack);