mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fulltext now ignores archived notes like it used to in the old implementation
This commit is contained in:
parent
d1f70efdb4
commit
52e0f838a9
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
PKG_DIR=dist/trilium-linux-x64-server
|
PKG_DIR=dist/trilium-linux-x64-server
|
||||||
NODE_VERSION=12.16.3
|
NODE_VERSION=12.18.3
|
||||||
|
|
||||||
if [ "$1" != "DONTCOPY" ]
|
if [ "$1" != "DONTCOPY" ]
|
||||||
then
|
then
|
||||||
|
@ -27,8 +27,9 @@ describe("Parser", () => {
|
|||||||
parsingContext: new ParsingContext({includeNoteContent: false})
|
parsingContext: new ParsingContext({includeNoteContent: false})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(rootExp.constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||||
expect(rootExp.tokens).toEqual(["hello", "hi"]);
|
expect(rootExp.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
|
expect(rootExp.subExpressions[0].tokens).toEqual(["hello", "hi"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fulltext parser with content", () => {
|
it("fulltext parser with content", () => {
|
||||||
@ -38,8 +39,11 @@ describe("Parser", () => {
|
|||||||
parsingContext: new ParsingContext({includeNoteContent: true})
|
parsingContext: new ParsingContext({includeNoteContent: true})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(rootExp.constructor.name).toEqual("OrExp");
|
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||||
const subs = rootExp.subExpressions;
|
expect(rootExp.subExpressions[0].constructor.name).toEqual("OrExp");
|
||||||
|
expect(rootExp.subExpressions[1].constructor.name).toEqual("PropertyComparisonExp");
|
||||||
|
|
||||||
|
const subs = rootExp.subExpressions[0].subExpressions;
|
||||||
|
|
||||||
expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
expect(subs[0].tokens).toEqual(["hello", "hi"]);
|
expect(subs[0].tokens).toEqual(["hello", "hi"]);
|
||||||
@ -149,8 +153,9 @@ describe("Parser", () => {
|
|||||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
const [firstSub, secondSub] = rootExp.subExpressions;
|
||||||
|
|
||||||
expect(firstSub.constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(firstSub.constructor.name).toEqual("AndExp");
|
||||||
expect(firstSub.tokens).toEqual(["hello"]);
|
expect(firstSub.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
|
expect(firstSub.subExpressions[0].tokens).toEqual(["hello"]);
|
||||||
|
|
||||||
expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
|
expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
|
||||||
expect(secondSub.attributeName).toEqual("mylabel");
|
expect(secondSub.attributeName).toEqual("mylabel");
|
||||||
|
@ -544,6 +544,23 @@ describe("Search", () => {
|
|||||||
expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Slovakia");
|
expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Slovakia");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("test that fulltext does not match archived notes", () => {
|
||||||
|
const italy = note("Italy").label("capital", "Rome");
|
||||||
|
const slovakia = note("Slovakia").label("capital", "Bratislava");
|
||||||
|
|
||||||
|
rootNote
|
||||||
|
.child(note("Reddit").label('archived', '', true)
|
||||||
|
.child(note('Post X'))
|
||||||
|
.child(note('Post Y')))
|
||||||
|
.child(note ('Reddit is bad'));
|
||||||
|
|
||||||
|
const parsingContext = new ParsingContext();
|
||||||
|
|
||||||
|
let searchResults = searchService.findNotesWithQuery('reddit', parsingContext);
|
||||||
|
expect(searchResults.length).toEqual(1);
|
||||||
|
expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Reddit is bad");
|
||||||
|
});
|
||||||
|
|
||||||
// FIXME: test what happens when we order without any filter criteria
|
// FIXME: test what happens when we order without any filter criteria
|
||||||
|
|
||||||
// it("comparison between labels", () => {
|
// it("comparison between labels", () => {
|
||||||
|
@ -115,7 +115,7 @@ class Note {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasAttribute(type, name) {
|
hasAttribute(type, name) {
|
||||||
return this.attributes.find(attr => attr.type === type && attr.name === name);
|
return !!this.attributes.find(attr => attr.type === type && attr.name === name);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLabelValue(name) {
|
getLabelValue(name) {
|
||||||
|
@ -75,11 +75,6 @@ class NoteCacheFlatTextExp extends Expression {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for leaf note it doesn't matter if "archived" label is inheritable or not
|
|
||||||
if (note.isArchived) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const foundAttrTokens = [];
|
const foundAttrTokens = [];
|
||||||
|
|
||||||
for (const attribute of note.ownedAttributes) {
|
for (const attribute of note.ownedAttributes) {
|
||||||
|
@ -13,7 +13,7 @@ const PROP_MAPPING = {
|
|||||||
"type": "type",
|
"type": "type",
|
||||||
"mime": "mime",
|
"mime": "mime",
|
||||||
"isprotected": "isProtected",
|
"isprotected": "isProtected",
|
||||||
"isarhived": "isArchived",
|
"isarchived": "isArchived",
|
||||||
"datecreated": "dateCreated",
|
"datecreated": "dateCreated",
|
||||||
"datemodified": "dateModified",
|
"datemodified": "dateModified",
|
||||||
"utcdatecreated": "utcDateCreated",
|
"utcdatecreated": "utcDateCreated",
|
||||||
|
@ -25,16 +25,24 @@ function getFulltext(tokens, parsingContext) {
|
|||||||
if (tokens.length === 0) {
|
if (tokens.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (parsingContext.includeNoteContent) {
|
|
||||||
return new OrExp([
|
let textSearchExpression;
|
||||||
|
|
||||||
|
if (parsingContext.includeNoteContent) {
|
||||||
|
textSearchExpression = new OrExp([
|
||||||
new NoteCacheFulltextExp(tokens),
|
new NoteCacheFulltextExp(tokens),
|
||||||
new NoteContentProtectedFulltextExp('*=*', tokens),
|
new NoteContentProtectedFulltextExp('*=*', tokens),
|
||||||
new NoteContentUnprotectedFulltextExp('*=*', tokens)
|
new NoteContentUnprotectedFulltextExp('*=*', tokens)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new NoteCacheFulltextExp(tokens);
|
textSearchExpression = new NoteCacheFulltextExp(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new AndExp([
|
||||||
|
textSearchExpression,
|
||||||
|
new PropertyComparisonExp("isarchived", comparatorBuilder("=", "false"))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOperator(str) {
|
function isOperator(str) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user