Skip to content

Build your personal knowledge base with Trilium Notes

fix searching by label

zadame25b965cb397
diff --git a/src/services/attribute_formatter.js b/src/services/attribute_formatter.js
index b7498bece3..f02e9f7319 100644
--- a/src/services/attribute_formatter.js
+++ b/src/services/attribute_formatter.js
@@ -28,7 +28,7 @@ function formatAttrForSearch(attr, searchWithValue) {
}
function formatValue(val) {
- if (!/[^\w_-]/.test(val)) {
+ if (!/[^\w_]/.test(val)) {
return val;
}
else if (!val.includes('"')) {
diff --git a/src/services/attributes.js b/src/services/attributes.js
index 569c74013d..8168dbe540 100644
--- a/src/services/attributes.js
+++ b/src/services/attributes.js
@@ -60,7 +60,11 @@ const BUILTIN_ATTRIBUTES = [
];
function getNotesWithLabel(name, value) {
- return searchService.searchNotes(formatAttrForSearch({type: 'label', name, value}, true));
+ const query = formatAttrForSearch({type: 'label', name, value}, true);
+ return searchService.searchNotes(query, {
+ includeArchivedNotes: true,
+ ignoreHoistedNote: true
+ });
}
function getNoteIdsWithLabels(names) {
diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js
index 502ce872e2..282f88be37 100644
--- a/src/services/search/services/search.js
+++ b/src/services/search/services/search.js
@@ -136,8 +136,8 @@ function parseQueryToExpression(query, searchContext) {
* @param {string} query
* @return {Note[]}
*/
-function searchNotes(query) {
- const searchResults = findResultsWithQuery(query, new SearchContext());
+function searchNotes(query, params = {}) {
+ const searchResults = findResultsWithQuery(query, new SearchContext(params));
return searchResults.map(sr => becca.notes[sr.noteId]);
}