From f0b25cf32a89f7d44bf2ce2af1b441d15a976a82 Mon Sep 17 00:00:00 2001 From: "d.buechler" <d.buechler@adito.de> Date: Mon, 4 Nov 2019 08:33:28 +0100 Subject: [PATCH] Fixed bug where an error was thrown if a field is used to search for duplicates and it's value was empty. These fields will now be ignored. --- process/DuplicateScanner_lib/process.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index db017f0987..a90a8d0a62 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -920,7 +920,7 @@ pResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore, pFormatValuesCons //No prefilter and no filterfields => No indexsearch if(preFilter == null && pFilterFieldValueRays.length < 1) return null; - + //If at this point the prefilter is null but a search has to be executed, add the ignorefilter manually that the search doesn't find the base record as duplicate to itself. //This is the case if no prefilter but indexfields are configured. if(preFilter == null) @@ -933,7 +933,7 @@ pResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore, pFormatValuesCons return null; possibleDuplicates = possibleDuplicates[indexsearch.HITS]; - logging.log("possibleDuplicates -> " + possibleDuplicates.length); + if(pUseExternalWebservice && possibleDuplicates.length > 0 && pFormatValuesConsumeWebserviceCallback != null) possibleDuplicates = pFormatValuesConsumeWebserviceCallback.apply(this, [possibleDuplicates]); @@ -1103,7 +1103,7 @@ _DuplicateScannerUtils._callIndexSearch = function(pTargetEntity, pPreFilterJson if(filterPatternConfig != null) filterPattern = indexsearch.buildPatternString(filterPatternConfig); - + //The indexPattern can't be null because it is required to run the search. if(indexPattern == null) return null; @@ -1181,28 +1181,25 @@ _DuplicateScannerUtils._buildFilterPatternConfig = function(pEntityFieldValueRay let INDEX_CONFIG_USE_FOR_SEARCH = 2; let filterPatternConfig = null; - //logging.log("pEntityFieldValueRays.length -> " + pEntityFieldValueRays.length); if(pEntityFieldValueRays.length > 1) { filterPatternConfig = indexsearch.createPatternConfig(); for (let i = 1; i < pEntityFieldValueRays.length; i++) { - let entityFieldValue = pEntityFieldValueRays[i][1].trim(); + let entityFieldValue = pEntityFieldValueRays[i][1]; let entityFieldName = pEntityFieldValueRays[i][0]; - + //if(pEntityFieldValueRays[i][INDEX_CONFIG_USE_FOR_SEARCH] == 0 || entityFieldValue == "") - if(entityFieldValue == "") + if(entityFieldValue == undefined || entityFieldValue == "") continue; - //logging.log("entityFieldValue -> " + entityFieldValue); - //logging.log("entityFieldName -> " + entityFieldName); - + entityFieldValue = entityFieldValue.trim(); + let indexField = indexsearch.lookupIndexField(pTargetEntity, entityFieldName); - //logging.log("indexField -> " + indexField); var filterTerm = indexsearch.createTerm(entityFieldValue) .setIndexField(indexField); - + if(pEntityFieldValueRays[i][INDEX_CONFIG_USE_FOR_SEARCH] == 1) { logging.log("Nutze fuzzy search -> "); -- GitLab