From 85f7b056d271f6df47ad409541997f53f7a6a077 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 19 Jul 2021 14:31:06 +0100 Subject: [PATCH 1/2] Fixing an issue with lucene equality searching, strings weren't handled correctly. --- packages/server/src/api/controllers/row/internalSearch.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index 7225ab633a..91cfdcbcb6 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -148,12 +148,16 @@ class QueryBuilder { } if (this.query.equal) { build(this.query.equal, (key, value) => { - return value ? `${key}:${luceneEscape(value.toLowerCase())}` : null + const escapedValue = luceneEscape(value.toLowerCase()) + // have to do the or to manage straight values, or strings + return value ? `(${key}:${escapedValue} OR ${key}:"${escapedValue}")` : null }) } if (this.query.notEqual) { build(this.query.notEqual, (key, value) => { - return value ? `!${key}:${luceneEscape(value.toLowerCase())}` : null + const escapedValue = luceneEscape(value.toLowerCase()) + // have to do the or to manage straight values, or strings + return value ? `(!${key}:${escapedValue} OR !${key}:"${escapedValue}")` : null }) } if (this.query.empty) { From 2bee1b6b560df2b53a5882664d06976074f8b3a1 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 19 Jul 2021 14:32:14 +0100 Subject: [PATCH 2/2] Linting. --- packages/server/src/api/controllers/row/internalSearch.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index 91cfdcbcb6..72f5e6e5c8 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -150,14 +150,18 @@ class QueryBuilder { build(this.query.equal, (key, value) => { const escapedValue = luceneEscape(value.toLowerCase()) // have to do the or to manage straight values, or strings - return value ? `(${key}:${escapedValue} OR ${key}:"${escapedValue}")` : null + return value + ? `(${key}:${escapedValue} OR ${key}:"${escapedValue}")` + : null }) } if (this.query.notEqual) { build(this.query.notEqual, (key, value) => { const escapedValue = luceneEscape(value.toLowerCase()) // have to do the or to manage straight values, or strings - return value ? `(!${key}:${escapedValue} OR !${key}:"${escapedValue}")` : null + return value + ? `(!${key}:${escapedValue} OR !${key}:"${escapedValue}")` + : null }) } if (this.query.empty) {