mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	search fixes WIP
This commit is contained in:
		| @@ -46,7 +46,8 @@ class NoteBuilder { | ||||
|             branchId: id(), | ||||
|             noteId: childNoteBuilder.note.noteId, | ||||
|             parentNoteId: this.note.noteId, | ||||
|             prefix | ||||
|             prefix, | ||||
|             notePosition: 10 | ||||
|         }); | ||||
|  | ||||
|         return this; | ||||
|   | ||||
| @@ -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", () => { | ||||
|   | ||||
| @@ -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"); | ||||
|     }); | ||||
| }); | ||||
|  | ||||
|   | ||||
| @@ -79,7 +79,6 @@ class NoteRevision extends Entity { | ||||
|             } | ||||
|  | ||||
|             this.content = res.content; | ||||
|  | ||||
|             if (this.isProtected) { | ||||
|                 if (protectedSessionService.isProtectedSessionAvailable()) { | ||||
|                     this.content = protectedSessionService.decrypt(this.content); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ function set(key, value) { | ||||
| } | ||||
|  | ||||
| function getHoistedNoteId() { | ||||
|     return namespace.get('hoistedNoteId'); | ||||
|     return namespace.get('hoistedNoteId') || 'root'; | ||||
| } | ||||
|  | ||||
| function getSourceId() { | ||||
|   | ||||
| @@ -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); | ||||
|                 } | ||||
|   | ||||
| @@ -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)); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user