From 65358cf10d3cfdf13da8b2aac8f0e266a5854626 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 2ec00c32b6a0d3c94902f52fa5b6b28c93eec9ac 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) {