diff --git a/src/services/search/expressions/note_content_fulltext.js b/src/services/search/expressions/note_content_fulltext.js
index f7758ef31..548578c2b 100644
--- a/src/services/search/expressions/note_content_fulltext.js
+++ b/src/services/search/expressions/note_content_fulltext.js
@@ -8,7 +8,7 @@ const protectedSessionService = require('../../protected_session');
const striptags = require('striptags');
const utils = require("../../utils");
-const ALLOWED_OPERATORS = ['*=*', '=', '*=', '=*', '~'];
+const ALLOWED_OPERATORS = ['*=*', '=', '*=', '=*', '%='];
const cachedRegexes = {};
@@ -25,7 +25,7 @@ class NoteContentFulltextExp extends Expression {
super();
if (!ALLOWED_OPERATORS.includes(operator)) {
- throw new Error(`Note content can be searched only with operators: ` + ALLOWED_OPERATORS.join(", "));
+ throw new Error(`Note content can be searched only with operators: ` + ALLOWED_OPERATORS.join(", ") + `, operator ${operator} given.`);
}
this.operator = operator;
@@ -62,13 +62,14 @@ class NoteContentFulltextExp extends Expression {
content = this.preprocessContent(content, type, mime);
- if (this.tokens.length === 1 && this.operator !== '*=*') {
+ if (this.tokens.length === 1) {
const [token] = this.tokens;
if ((this.operator === '=' && token === content)
|| (this.operator === '*=' && content.endsWith(token))
|| (this.operator === '=*' && content.startsWith(token))
- || (this.operator === '~' && getRegex(token).test(content))) {
+ || (this.operator === '*=*' && content.includes(token))
+ || (this.operator === '%=' && getRegex(token).test(content))) {
resultNoteSet.add(becca.notes[noteId]);
}
diff --git a/src/services/search/services/build_comparator.js b/src/services/search/services/build_comparator.js
index 0776b834f..6d3ba463a 100644
--- a/src/services/search/services/build_comparator.js
+++ b/src/services/search/services/build_comparator.js
@@ -18,7 +18,7 @@ const stringComparators = {
"*=": comparedValue => (val => val && val.endsWith(comparedValue)),
"=*": comparedValue => (val => val && val.startsWith(comparedValue)),
"*=*": comparedValue => (val => val && val.includes(comparedValue)),
- "~": comparedValue => (val => val && !!getRegex(comparedValue).test(val)),
+ "%=": comparedValue => (val => val && !!getRegex(comparedValue).test(val)),
};
const numericComparators = {
diff --git a/src/services/search/services/lex.js b/src/services/search/services/lex.js
index 5234900f7..c6bdc2dfd 100644
--- a/src/services/search/services/lex.js
+++ b/src/services/search/services/lex.js
@@ -9,7 +9,7 @@ function lex(str) {
let currentWord = '';
function isSymbolAnOperator(chr) {
- return ['=', '*', '>', '<', '!', "-", "+"].includes(chr);
+ return ['=', '*', '>', '<', '!', "-", "+", '%'].includes(chr);
}
function isPreviousSymbolAnOperator() {
diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.js
index 32ce9eeec..8ab99fe31 100644
--- a/src/services/search/services/parse.js
+++ b/src/services/search/services/parse.js
@@ -40,7 +40,7 @@ function getFulltext(tokens, searchContext) {
}
function isOperator(str) {
- return str.match(/^[!=<>*~]+$/);
+ return str.match(/^[!=<>*%]+$/);
}
function getExpression(tokens, searchContext, level = 0) {
diff --git a/trilium.iml b/trilium.iml
index 6905b014e..cffe441d0 100644
--- a/trilium.iml
+++ b/trilium.iml
@@ -13,9 +13,10 @@
+
-
+
\ No newline at end of file