From 81181eacc07d6cbda47efc6208ec899d4cd12d10 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Wed, 30 Oct 2019 16:38:04 +0100
Subject: [PATCH] Fixed bug: If a field of a filter had no value it would throw
 a core exception because no pattern with an empty value could be created. Now
 the value gets trimmed and in case of emptyness ignored. Workaround, if the
 prefilter json contains an empty value it gets translated to null by
 indexsearch.buildQueryFromSearchCondition with which nothing would be found.
 The null value now gets temporarily replaced. Hast to be removed when the api
 has been fixed! Specific line to remove: indexPattern =
 indexPattern.replace(null, "");//todo remove if api has been fixed

---
 process/DuplicateScanner_lib/process.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index 971cd1f9a4..db017f0987 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -1097,6 +1097,8 @@ _DuplicateScannerUtils._callIndexSearch = function(pTargetEntity, pPreFilterJson
     //The pPreFilterJson is never null because it always contains at least the default ignore record filter
     indexPattern = indexsearch.buildQueryFromSearchCondition(pPreFilterJson);
 
+    indexPattern = indexPattern.replace(null, "");//todo remove if api has been fixed
+
     let filterPatternConfig = _DuplicateScannerUtils._buildFilterPatternConfig(pEntityFieldValueRays, pTargetEntity);
 
     if(filterPatternConfig != null)
@@ -1116,8 +1118,7 @@ _DuplicateScannerUtils._callIndexSearch = function(pTargetEntity, pPreFilterJson
     if(filterPattern != null)
         indexQuery = indexQuery.addFilter(filterPattern);
     
-    logging.log("indexQuery.getPattern -> " + indexQuery.getPattern());
-    logging.log("indexQuery.getFilters -> " + indexQuery.getFilters());
+    logging.log("indexQuery: PATTERN + FILTERS -> " + indexQuery.getPattern() + " " + indexQuery.getFilters());
 
     return indexsearch.searchIndex(indexQuery);
 }
@@ -1186,7 +1187,7 @@ _DuplicateScannerUtils._buildFilterPatternConfig = function(pEntityFieldValueRay
         filterPatternConfig = indexsearch.createPatternConfig();
         for (let i = 1; i < pEntityFieldValueRays.length; i++)
         {
-            let entityFieldValue = pEntityFieldValueRays[i][1];
+            let entityFieldValue = pEntityFieldValueRays[i][1].trim();
             let entityFieldName = pEntityFieldValueRays[i][0];
 
             //if(pEntityFieldValueRays[i][INDEX_CONFIG_USE_FOR_SEARCH] == 0 || entityFieldValue == "")
-- 
GitLab