Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
search will also look for type and mime by default
zadamb793f8cb8870
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.jsindex 5e4c3e3fdd..1d3c7231c1 100644--- a/src/public/app/widgets/note_tree.js+++ b/src/public/app/widgets/note_tree.js@@ -851,6 +851,10 @@ export default class NoteTreeWidget extends TabAwareWidget {if (!foundChildNode) {if (logErrors) {+ // besides real errors this can be also caused by hiding of e.g. included images+ // these are real notes with real notePath, user can display them in a detail+ // but they don't have a node in the tree+ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteId}, requested path is ${notePath}`);}diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.jsindex a00682b29a..6fa8ca9372 100644--- a/src/services/note_cache/entities/note.js+++ b/src/services/note_cache/entities/note.js@@ -160,7 +160,7 @@ class Note {return this.flatTextCache;}- this.flatTextCache = this.noteId + ' ';+ this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime;for (const branch of this.parentBranches) {if (branch.prefix) {diff --git a/src/services/search/expressions/note_cache_flat_text.js b/src/services/search/expressions/note_cache_flat_text.jsindex c503d7653d..9443161401 100644--- a/src/services/search/expressions/note_cache_flat_text.js+++ b/src/services/search/expressions/note_cache_flat_text.js@@ -36,6 +36,12 @@ class NoteCacheFlatTextExp extends Expression {const foundAttrTokens = [];+ for (const token of tokens) {+ if (note.type.includes(token) || note.mime.includes(token)) {+ foundAttrTokens.push(token);+ }+ }+for (const attribute of note.ownedAttributes) {for (const token of tokens) {if (attribute.name.toLowerCase().includes(token)@@ -77,10 +83,18 @@ class NoteCacheFlatTextExp extends Expression {const foundAttrTokens = [];+ for (const token of this.tokens) {+ if (note.type.includes(token) || note.mime.includes(token)) {+ foundAttrTokens.push(token);+ }+ }+for (const attribute of note.ownedAttributes) {+ const lcName = attribute.name.toLowerCase();+ const lcValue = attribute.value.toLowerCase();+for (const token of this.tokens) {- if (attribute.name.toLowerCase().includes(token)- || attribute.value.toLowerCase().includes(token)) {+ if (lcName.includes(token) || lcValue.includes(token)) {foundAttrTokens.push(token);}}diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex 1b2b27e71e..51b45bedd9 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -146,6 +146,14 @@ function highlightSearchResults(searchResults, highlightedTokens) {result.highlightedNotePathTitle = result.notePathTitle;+ if (highlightedTokens.find(token => note.type.includes(token))) {+ result.highlightedNotePathTitle += ` <small>type: ${note.type}</small>`;+ }++ if (highlightedTokens.find(token => note.mime.includes(token))) {+ result.highlightedNotePathTitle += ` <small>mime: ${note.mime}</small>`;+ }+for (const attr of note.attributes) {if (highlightedTokens.find(token => attr.name.includes(token) || attr.value.includes(token))) {result.highlightedNotePathTitle += ` <small>${formatAttribute(attr)}</small>`;