search fixes WIP

This commit is contained in:
zadam
2020-12-14 23:59:05 +01:00
parent fccce2ff1e
commit 3a12181a57
7 changed files with 18 additions and 9 deletions

View File

@@ -79,7 +79,6 @@ class NoteRevision extends Entity {
}
this.content = res.content;
if (this.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
this.content = protectedSessionService.decrypt(this.content);

View File

@@ -25,7 +25,7 @@ function set(key, value) {
}
function getHoistedNoteId() {
return namespace.get('hoistedNoteId');
return namespace.get('hoistedNoteId') || 'root';
}
function getSourceId() {

View File

@@ -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);
}

View File

@@ -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));