Skip to content

Build your personal knowledge base with Trilium Notes

note. prefix also separates fulltext tokens from expression tokens

zadamd037420acb08
diff --git a/spec/search/lexer.spec.js b/spec/search/lexer.spec.js
index 8cce5e6c0e..e781d9b43f 100644
--- a/spec/search/lexer.spec.js
+++ b/spec/search/lexer.spec.js
@@ -75,6 +75,19 @@ describe("Lexer expression", () => {
]);
});
+ it("note. prefix also separates fulltext from expression", () => {
+ expect(lex(`hello fulltext note.labels.capital = Prague`).expressionTokens.map(t => t.token))
+ .toEqual(["note", ".", "labels", ".", "capital", "=", "prague"]);
+ });
+
+ it("note. prefix in quotes will note start expression", () => {
+ expect(lex(`hello fulltext "note.txt"`).expressionTokens.map(t => t.token))
+ .toEqual([]);
+
+ expect(lex(`hello fulltext "note.txt"`).fulltextTokens.map(t => t.token))
+ .toEqual(["hello", "fulltext", "note.txt"]);
+ });
+
it("complex expressions with and, or and parenthesis", () => {
expect(lex(`# (#label=text OR #second=text) AND ~relation`).expressionTokens.map(t => t.token))
.toEqual(["#", "(", "#label", "=", "text", "or", "#second", "=", "text", ")", "and", "~relation"]);
diff --git a/src/services/search/services/lex.js b/src/services/search/services/lex.js
index 821a3e2fc8..4f6ab8b97c 100644
--- a/src/services/search/services/lex.js
+++ b/src/services/search/services/lex.js
@@ -83,6 +83,10 @@ function lex(str) {
continue;
}
else if (!quotes) {
+ if (!fulltextEnded && currentWord === 'note' && chr === '.') {
+ fulltextEnded = true;
+ }
+
if (chr === '#' || chr === '~') {
if (!fulltextEnded) {
fulltextEnded = true;