mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
improvements to saved search
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user