Skip to content

Build your personal knowledge base with Trilium Notes

fix orderby with multiple labels, closes #4220

zadam7b662b04ff55
diff --git a/spec/search/lexer.spec.js b/spec/search/lexer.spec.js
index b69b008071..1533bf56ae 100644
--- a/spec/search/lexer.spec.js
+++ b/spec/search/lexer.spec.js
@@ -4,6 +4,9 @@ describe("Lexer fulltext", () => {
it("simple lexing", () => {
expect(lex("hello world").fulltextTokens.map(t => t.token))
.toEqual(["hello", "world"]);
+
+ expect(lex("hello, world").fulltextTokens.map(t => t.token))
+ .toEqual(["hello", "world"]);
});
it("use quotes to keep words together", () => {
@@ -147,6 +150,11 @@ describe("Lexer expression", () => {
expect(lex(`# not(#capital) and note.noteId != "root"`).expressionTokens.map(t => t.token))
.toEqual(["#", "not", "(", "#capital", ")", "and", "note", ".", "noteid", "!=", "root"]);
});
+
+ it("order by multiple labels", () => {
+ expect(lex(`# orderby #a,#b`).expressionTokens.map(t => t.token))
+ .toEqual(["#", "orderby", "#a", ",", "#b"]);
+ });
});
describe("Lexer invalid queries and edge cases", () => {
diff --git a/src/services/search/services/lex.js b/src/services/search/services/lex.js
index cefcd53f30..ddee0840f7 100644
--- a/src/services/search/services/lex.js
+++ b/src/services/search/services/lex.js
@@ -11,7 +11,7 @@ function lex(str) {
let currentWord = '';
function isSymbolAnOperator(chr) {
- return ['=', '*', '>', '<', '!', "-", "+", '%'].includes(chr);
+ return ['=', '*', '>', '<', '!', "-", "+", '%', ','].includes(chr);
}
function isPreviousSymbolAnOperator() {
@@ -128,6 +128,10 @@ function lex(str) {
}
}
+ if (chr === ',') {
+ continue;
+ }
+
currentWord += chr;
}