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
fixed bug in search where note with inherited attribute is not matched when the owning note is not matched, #2457
zadamb8eeb0371c42
diff --git a/spec/search/search.spec.js b/spec/search/search.spec.jsindex 795c4f7f2c..35da251505 100644--- a/spec/search/search.spec.js+++ b/spec/search/search.spec.js@@ -157,6 +157,21 @@ describe("Search", () => {expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();});+ it("inherited label comparison", () => {+ rootNote+ .child(note("Europe")+ .label('country', '', true)+ .child(note("Austria"))+ .child(note("Czech Republic"))+ );++ const searchContext = new SearchContext();++ const searchResults = searchService.findResultsWithQuery('austria #country', searchContext);+ expect(searchResults.length).toEqual(1);+ expect(findNoteByTitle(searchResults, "Austria")).toBeTruthy();+ });+it("numeric label comparison fallback to string comparison", () => {// dates should not be coerced into numbers which would then give wrong numbersdiff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.jsindex b72c2d69b1..f28185ebcc 100644--- a/src/services/search/expressions/attribute_exists.js+++ b/src/services/search/expressions/attribute_exists.js@@ -23,20 +23,18 @@ class AttributeExistsExp extends Expression {for (const attr of attrs) {const note = attr.note;- if (inputNoteSet.hasNoteId(note.noteId)) {- if (attr.isInheritable) {- resultNoteSet.addAll(note.getSubtreeNotesIncludingTemplated());- }- else if (note.isTemplate()) {- resultNoteSet.addAll(note.getTemplatedNotes());- }- else {- resultNoteSet.add(note);- }+ if (attr.isInheritable) {+ resultNoteSet.addAll(note.getSubtreeNotesIncludingTemplated());+ }+ else if (note.isTemplate()) {+ resultNoteSet.addAll(note.getTemplatedNotes());+ }+ else {+ resultNoteSet.add(note);}}- return resultNoteSet;+ return resultNoteSet.intersection(inputNoteSet);}}