implemented "search in subtree"

This commit is contained in:
zadam
2020-12-05 23:00:28 +01:00
parent b0e5ab7533
commit 90d33f56c3
13 changed files with 98 additions and 82 deletions

View File

@@ -6,30 +6,6 @@ const log = require('../../services/log');
const scriptService = require('../../services/script');
const searchService = require('../../services/search/services/search');
function searchNotes(req) {
const searchContext = new SearchContext({
includeNoteContent: req.query.includeNoteContent === 'true',
excludeArchived: req.query.excludeArchived === 'true',
fuzzyAttributeSearch: req.query.fuzzyAttributeSearch === 'true'
});
const {count, results} = searchService.searchTrimmedNotes(req.params.searchString, searchContext);
try {
return {
success: !searchContext.hasError(),
message: searchContext.getError(),
count,
results
}
}
catch {
return {
success: false
}
}
}
async function searchFromNote(req) {
const note = repository.getNote(req.params.noteId);
@@ -58,6 +34,7 @@ async function searchFromNote(req) {
else if (searchString) {
const searchContext = new SearchContext({
includeNoteContent: note.getLabelValue('includeNoteContent') === 'true',
subTreeNoteId: note.getLabelValue('subTreeNoteId'),
excludeArchived: true,
fuzzyAttributeSearch: false
});
@@ -197,7 +174,6 @@ function formatValue(val) {
}
module.exports = {
searchNotes,
searchFromNote,
getRelatedNotes
};

View File

@@ -254,7 +254,6 @@ function register(app) {
route(POST, '/api/sender/image', [auth.checkToken, uploadMiddleware], senderRoute.uploadImage, apiResultHandler);
route(POST, '/api/sender/note', [auth.checkToken], senderRoute.saveNote, apiResultHandler);
apiRoute(GET, '/api/search/:searchString', searchRoute.searchNotes);
apiRoute(GET, '/api/search-note/:noteId', searchRoute.searchFromNote);
apiRoute(POST, '/api/search-related', searchRoute.getRelatedNotes);