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 fixes WIP
zadam3a12181a57e9
diff --git a/spec/search/note_cache_mocking.js b/spec/search/note_cache_mocking.jsindex 0554093a9c..2912fe0c21 100644--- a/spec/search/note_cache_mocking.js+++ b/spec/search/note_cache_mocking.js@@ -46,7 +46,8 @@ class NoteBuilder {branchId: id(),noteId: childNoteBuilder.note.noteId,parentNoteId: this.note.noteId,- prefix+ prefix,+ notePosition: 10});return this;diff --git a/spec/search/search.spec.js b/spec/search/search.spec.jsindex 861b902d80..1320027fc6 100644--- a/spec/search/search.spec.js+++ b/spec/search/search.spec.js@@ -13,7 +13,7 @@ describe("Search", () => {noteCache.reset();rootNote = new NoteBuilder(new Note(noteCache, {noteId: 'root', title: 'root'}));- new Branch(noteCache, {branchId: 'root', noteId: 'root', parentNoteId: 'none'});+ new Branch(noteCache, {branchId: 'root', noteId: 'root', parentNoteId: 'none', notePosition: 10});});it("simple path match", () => {diff --git a/spec/search/value_extractor.spec.js b/spec/search/value_extractor.spec.jsindex 07b3cafd5a..12fd07ffaa 100644--- a/spec/search/value_extractor.spec.js+++ b/spec/search/value_extractor.spec.js@@ -59,12 +59,12 @@ describe("Value extractor", () => {let valueExtractor = new ValueExtractor(["note", "relations", "neighbor", "labels", "capital"]);expect(valueExtractor.validate()).toBeFalsy();- expect(valueExtractor.extract(austria.note)).toEqual("prague");+ expect(valueExtractor.extract(austria.note)).toEqual("Prague");valueExtractor = new ValueExtractor(["~neighbor", "labels", "capital"]);expect(valueExtractor.validate()).toBeFalsy();- expect(valueExtractor.extract(austria.note)).toEqual("prague");+ expect(valueExtractor.extract(austria.note)).toEqual("Prague");});});diff --git a/src/entities/note_revision.js b/src/entities/note_revision.jsindex a51f27e254..eee980182c 100644--- a/src/entities/note_revision.js+++ b/src/entities/note_revision.js@@ -79,7 +79,6 @@ class NoteRevision extends Entity {}this.content = res.content;-if (this.isProtected) {if (protectedSessionService.isProtectedSessionAvailable()) {this.content = protectedSessionService.decrypt(this.content);diff --git a/src/services/cls.js b/src/services/cls.jsindex b675e21754..a7b10e802b 100644--- a/src/services/cls.js+++ b/src/services/cls.js@@ -25,7 +25,7 @@ function set(key, value) {}function getHoistedNoteId() {- return namespace.get('hoistedNoteId');+ return namespace.get('hoistedNoteId') || 'root';}function getSourceId() {diff --git a/src/services/search/expressions/label_comparison.js b/src/services/search/expressions/label_comparison.jsindex 143c41b6ed..817fe5c28c 100644--- a/src/services/search/expressions/label_comparison.js+++ b/src/services/search/expressions/label_comparison.js@@ -9,7 +9,7 @@ class LabelComparisonExp extends Expression {super();this.attributeType = attributeType;- this.attributeName = attributeName;+ this.attributeName = attributeName.toLowerCase();this.comparator = comparator;}@@ -19,8 +19,9 @@ class LabelComparisonExp extends Expression {for (const attr of attrs) {const note = attr.note;+ const value = attr.value ? attr.value.toLowerCase() : attr.value;- if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(attr.value)) {+ if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(value)) {if (attr.isInheritable) {resultNoteSet.addAll(note.subtreeNotesIncludingTemplated);}diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex 224e55c181..c40fb6d19b 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -35,7 +35,15 @@ function findNotesWithExpression(expression, searchContext) {const noteSet = expression.execute(allNoteSet, executionContext);const searchResults = noteSet.notes- .map(note => executionContext.noteIdToNotePath[note.noteId] || noteCacheService.getSomePath(note))+ .map(note => {+ const zzz = executionContext.noteIdToNotePath[note.noteId] || noteCacheService.getSomePath(note)++ if (!zzz) {+ console.log("missing path", note);+ }++ return zzz;+ }).filter(notePathArray => notePathArray.includes(cls.getHoistedNoteId())).map(notePathArray => new SearchResult(notePathArray));