From 5fd57ad3cf638101c26ac7f53d09add3a9162dc3 Mon Sep 17 00:00:00 2001
From: "a.niebisch" <a.niebisch@adito.de>
Date: Wed, 24 Jul 2019 14:24:40 +0200
Subject: [PATCH] =?UTF-8?q?#1041341=20Refactoring=20der=20Idnexgruppen.=20?=
 =?UTF-8?q?-=20Neue=20Konstanten=20f=C3=BCr=20Systemfelder=20#1041405=20Pe?=
 =?UTF-8?q?rson=20und=20Org=20angepasst=20auf=20ContactId=20als=20uid?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../recordcontainers/childgroup/query.js      |  4 +-
 .../recordcontainers/groupextension/query.js  |  4 +-
 .../recordcontainers/index/query.js           |  6 +--
 .../recordcontainers/index/query.js           |  6 +--
 .../recordcontainers/index/query.js           |  6 +--
 .../index/affectedConsumerIds.js              |  6 ++-
 .../recordcontainers/index/affectedIds.js     | 38 +++++++++++++---
 .../recordcontainers/index/query.js           | 10 ++---
 .../index/affectedConsumerIds.js              | 14 ++++--
 .../recordcontainers/index/affectedIds.js     | 44 +++++++++++++++----
 .../recordcontainers/index/query.js           |  8 ++--
 .../recordcontainers/index/query.js           |  6 +--
 .../recordcontainers/index/query.js           |  6 +--
 13 files changed, 111 insertions(+), 47 deletions(-)

diff --git a/entity/Address_entity/recordcontainers/childgroup/query.js b/entity/Address_entity/recordcontainers/childgroup/query.js
index 968036a197..4cf4bcc1d9 100644
--- a/entity/Address_entity/recordcontainers/childgroup/query.js
+++ b/entity/Address_entity/recordcontainers/childgroup/query.js
@@ -10,9 +10,9 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 
-sqlQuery = "select ADDRESS.ADDRESSID as uid" 
+sqlQuery = 'select ADDRESS.ADDRESSID as "_uid_"' 
     + ', ADDRESS.ADDRESSID'
-    + ', ADDRESS.ZIP as "ZIP.value"' 
+    + ', ADDRESS.ZIP as ZIP' 
     + ', ADDRESS.CITY as CITY' 
     + ', ADDRESS.COUNTRY' 
     + ', ADDRESS.ADDRESS' 
diff --git a/entity/Communication_entity/recordcontainers/groupextension/query.js b/entity/Communication_entity/recordcontainers/groupextension/query.js
index 7faad202b0..175c25d9aa 100644
--- a/entity/Communication_entity/recordcontainers/groupextension/query.js
+++ b/entity/Communication_entity/recordcontainers/groupextension/query.js
@@ -10,7 +10,9 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 
-sqlQuery = "select COMMUNICATION.COMMUNICATIONID, COMMUNICATION.ADDR from COMMUNICATION "
+sqlQuery = "select COMMUNICATION.COMMUNICATIONID" 
+    + ", COMMUNICATION.ADDR" 
+    + " from COMMUNICATION"
  + (queryCondition || "") 
  + " order by COMMUNICATION.COMMUNICATIONID ";
 
diff --git a/entity/Contract_entity/recordcontainers/index/query.js b/entity/Contract_entity/recordcontainers/index/query.js
index 3a7783950d..2c01a5477f 100644
--- a/entity/Contract_entity/recordcontainers/index/query.js
+++ b/entity/Contract_entity/recordcontainers/index/query.js
@@ -15,12 +15,12 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select CONTRACTID as uid, " 
+sqlQuery = 'select CONTRACTID as "_uid_", ' 
     + sqlHelper.concat(["CONTRACTCODE", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.contractStatus(), "CONTRACTSTATUS")], " | ")
-    + " as title, " 
+    + ' as "_title_", '
     + sqlHelper.concat(["ORGANISATION.NAME", "'| " + translate.text("Type of contract") + ":'", 
             KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.contractType(), "CONTRACTTYPE")]) 
-    + " as description" 
+    + ' as "_description_"' 
     + ", CONTRACTCODE "
     + ", CUSTOMERCODE " 
     + ", CONTRACT.CONTACT_ID"
diff --git a/entity/Offer_entity/recordcontainers/index/query.js b/entity/Offer_entity/recordcontainers/index/query.js
index 7aed701b0b..73e6a530c0 100644
--- a/entity/Offer_entity/recordcontainers/index/query.js
+++ b/entity/Offer_entity/recordcontainers/index/query.js
@@ -16,11 +16,11 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select OFFERID as uid, " 
+sqlQuery = 'select OFFERID as "_uid_", ' 
     + sqlHelper.concat([sqlHelper.cast("OFFERCODE", SQLTYPES.CHAR, 10), KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.offerStatus(), "OFFER.STATUS")], " | ")
-    + " as title, " 
+    + ' as "_title_", ' 
     + sqlHelper.concat(["ORGANISATION.NAME", "'| " + translate.text("Description") + ":'", sqlHelper.castLob("OFFER.INFO", 250)])  
-    + " as description" 
+    + ' as "_description_"' 
     + ", OFFERCODE"
     + ", CUSTOMERCODE " 
     + ", OFFER.CONTACT_ID "
diff --git a/entity/Order_entity/recordcontainers/index/query.js b/entity/Order_entity/recordcontainers/index/query.js
index 57bca0642d..2a452fc682 100644
--- a/entity/Order_entity/recordcontainers/index/query.js
+++ b/entity/Order_entity/recordcontainers/index/query.js
@@ -15,11 +15,11 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select SALESORDERID as uid, " 
+sqlQuery = 'select SALESORDERID as "_uid_", ' 
     + sqlHelper.concat([sqlHelper.cast("SALESORDERCODE", SQLTYPES.CHAR, 10), KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesorderState(), "SALESORDER.STATUS")], " | ")
-    + " as title, " 
+    + ' as "_title_", ' 
     + sqlHelper.concat(["ORGANISATION.NAME"], " | ") 
-    + " as description" 
+    + ' as "_description_" ' 
     + ", SALESORDERCODE" 
     + ", CUSTOMERCODE"
     + ", SALESORDER.CONTACT_ID"
diff --git a/entity/Organisation_entity/recordcontainers/index/affectedConsumerIds.js b/entity/Organisation_entity/recordcontainers/index/affectedConsumerIds.js
index e0298d25cc..9e9351b3c7 100644
--- a/entity/Organisation_entity/recordcontainers/index/affectedConsumerIds.js
+++ b/entity/Organisation_entity/recordcontainers/index/affectedConsumerIds.js
@@ -40,7 +40,8 @@ function addIds(pRes, pConsumerName, pIds)
 function addAddressIds(pRes, pCurrId)
 {
     var sql, ids;
-    sql = "select ADDRESS.ADDRESSID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.ORGANISATION_ID = '" + pCurrId + "'";
+//    sql = "select ADDRESS.ADDRESSID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.ORGANISATION_ID = '" + pCurrId + "'";
+    sql = "select ADDRESS.ADDRESSID from ADDRESS where ADDRESS.CONTACT_ID = '" + pCurrId + "'";
     ids = db.array(db.COLUMN, sql, alias, 0 , 1 * datetime.ONE_MINUTE);
     
     addIds(pRes, "Addresses", ids);
@@ -49,7 +50,8 @@ function addAddressIds(pRes, pCurrId)
 function addCommunicationIds(pRes, pCurrId)
 {
     var sql, ids;
-    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.ORGANISATION_ID = '" + pCurrId + "'";
+//    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.ORGANISATION_ID = '" + pCurrId + "'";
+    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION where COMMUNICATION.CONTACT_ID = '" + pCurrId + "'";
     ids = db.array(db.COLUMN, sql, alias, 0 , 1 * datetime.ONE_MINUTE);
     
     addIds(pRes, "Communications", ids);
diff --git a/entity/Organisation_entity/recordcontainers/index/affectedIds.js b/entity/Organisation_entity/recordcontainers/index/affectedIds.js
index 7d50c9deb4..dc4472218b 100644
--- a/entity/Organisation_entity/recordcontainers/index/affectedIds.js
+++ b/entity/Organisation_entity/recordcontainers/index/affectedIds.js
@@ -13,24 +13,48 @@ infoContainer =  IndexsearchUtils.createAffectedInfoContainer(idValue, null, var
     ,function (){return vars.get("$local.oldvalues")}
     ,function (){return vars.get("$local.values")});
 
+//switch (tableName)
+//{
+//    case "ORGANISATION":
+//        res = [idValue];
+//        break;    
+//    case "CONTACT":
+//        res = db.array(db.COLUMN, "select CONTACT.ORGANISATION_ID from CONTACT where CONTACT.PERSON_ID is null and CONTACT.CONTACTID = '" + idValue + "'");
+//        break;
+//    case "ADDRESS":
+//        res = IndexsearchUtils.getAffectedIdValues("ORGANISATION_ID", infoContainer, function (id){
+//            return db.array(db.COLUMN, ["select CONTACT.ORGANISATION_ID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID is null and ADDRESS.ADDRESSID = ?", [
+//                    [id, SqlUtils.getSingleColumnType("ADDRESS", "ADDRESSID")]
+//            ]]);
+//        });
+//        break;
+//    case "COMMUNICATION":
+//        res = IndexsearchUtils.getAffectedIdValues("ORGANISATION_ID", infoContainer, function (id){
+//            return db.array(db.COLUMN, ["select CONTACT.ORGANISATION_ID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID is null and where COMMUNICATIONID = ?", [
+//                    [id, SqlUtils.getSingleColumnType("COMMUNICATION", "COMMUNICATIONID")]
+//            ]]);
+//        });
+//        break;
+//}
+
 switch (tableName)
 {
-    case "ORGANISATION":
+    case "CONTACT":
         res = [idValue];
         break;    
-    case "CONTACT":
-        res = db.array(db.COLUMN, "select CONTACT.ORGANISATION_ID from CONTACT where CONTACT.PERSON_ID is null and CONTACT.CONTACTID = '" + idValue + "'");
+    case "ORGANISATION":
+        res = db.array(db.COLUMN, "select CONTACT.CONTACTID from CONTACT where CONTACT.PERSON_ID is null and CONTACT.ORGANISATION_ID = '" + idValue + "'");
         break;
     case "ADDRESS":
-        res = IndexsearchUtils.getAffectedIdValues("ORGANISATION_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select CONTACT.ORGANISATION_ID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID is null and ADDRESS.ADDRESSID = ?", [
+        res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
+            return db.array(db.COLUMN, ["select ADDRESS.CONTACT_ID from ADDRESS where ADDRESS.ADDRESSID = ?", [
                     [id, SqlUtils.getSingleColumnType("ADDRESS", "ADDRESSID")]
             ]]);
         });
         break;
     case "COMMUNICATION":
-        res = IndexsearchUtils.getAffectedIdValues("ORGANISATION_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select CONTACT.ORGANISATION_ID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID is null and where COMMUNICATIONID = ?", [
+        res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
+            return db.array(db.COLUMN, ["select COMMUNICATION.CONTACT_ID from COMMUNICATION where COMMUNICATIONID = ?", [
                     [id, SqlUtils.getSingleColumnType("COMMUNICATION", "COMMUNICATIONID")]
             ]]);
         });
diff --git a/entity/Organisation_entity/recordcontainers/index/query.js b/entity/Organisation_entity/recordcontainers/index/query.js
index 68a86d5b62..8962918927 100644
--- a/entity/Organisation_entity/recordcontainers/index/query.js
+++ b/entity/Organisation_entity/recordcontainers/index/query.js
@@ -13,22 +13,22 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select ORGANISATION.ORGANISATIONID as uid"
+sqlQuery = 'select CONTACT.CONTACTID as "_uid_" '
     + ", " + sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"]) 
-    + " as title "
+    + ' as "_title_" '
     + ", " + sqlHelper.concat([
          sqlHelper.concat(["defaultAddress.ADDRESS", "defaultAddress.BUILDINGNO", "'-'"
             ,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"])
         ,sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"])
         ,sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"])
-        ], " | ") + " as description "
+        ], " | ") + ' as "_description_"'
     //additional indexed fields
     + ", ORGANISATION.ORGANISATIONID"
     + ", ORGANISATION.NAME"
     + ", ORGANISATION.CUSTOMERCODE"
     + ", CONTACT.CONTACTID"
-    + ", (" + CommUtil.getStandardSubSqlPhone() + ') as "STANDARD_PHONE_COMMUNICATION.value"'
-    + ", (" + CommUtil.getStandardSubSqlMail() + ') as "STANDARD_EMAIL_COMMUNICATION.value"'
+    + ", (" + CommUtil.getStandardSubSqlPhone() + ") as STANDARD_PHONE_COMMUNICATION"
+    + ", (" + CommUtil.getStandardSubSqlMail() + ") as STANDARD_EMAIL_COMMUNICATION"
     + " from ORGANISATION "
     + " join CONTACT on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null "
     + " left join ADDRESS defaultAddress on defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID "
diff --git a/entity/Person_entity/recordcontainers/index/affectedConsumerIds.js b/entity/Person_entity/recordcontainers/index/affectedConsumerIds.js
index 679911a6c8..ba72575bc7 100644
--- a/entity/Person_entity/recordcontainers/index/affectedConsumerIds.js
+++ b/entity/Person_entity/recordcontainers/index/affectedConsumerIds.js
@@ -41,7 +41,8 @@ function addIds(pRes, pConsumerName, pIds)
 function addPersAddressIds(pRes, pCurrId)
 {
     var sql, ids;
-    sql = "select ADDRESS.ADDRESSID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID = '" + pCurrId + "'";
+//    sql = "select ADDRESS.ADDRESSID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID = '" + pCurrId + "'";
+    sql = "select ADDRESS.ADDRESSID from ADDRESS where ADDRESS.CONTACT_ID = '" + pCurrId + "'";
     ids = db.array(db.COLUMN, sql, alias, 0 , 1 * datetime.ONE_MINUTE);
     addIds(pRes, "PersAddresses", ids);
 }
@@ -49,10 +50,16 @@ function addPersAddressIds(pRes, pCurrId)
 function addOrgAddressIds(pRes, pCurrId)
 {
     var sql, ids;
+//    sql = "select CONTACT.ADDRESS_ID from ORGANISATION " 
+//        + "join CONTACT on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null " 
+//        + "where ORGANISATION.ORGANISATIONID  = ( " 
+//        + "select c.ORGANISATION_ID FROM CONTACT as c where c.PERSON_ID = '" + pCurrId 
+//        + "')";
+//    
     sql = "select CONTACT.ADDRESS_ID from ORGANISATION " 
         + "join CONTACT on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null " 
         + "where ORGANISATION.ORGANISATIONID  = ( " 
-        + "select c.ORGANISATION_ID FROM CONTACT as c where c.PERSON_ID = '" + pCurrId 
+        + "select c.ORGANISATION_ID FROM CONTACT as c where c.CONTACTID = '" + pCurrId 
         + "')";
     
     ids = db.array(db.COLUMN, sql, alias, 0 , 1 * datetime.ONE_MINUTE);
@@ -62,7 +69,8 @@ function addOrgAddressIds(pRes, pCurrId)
 function addCommunicationIds(pRes, pCurrId)
 {
     var sql, ids;
-    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID = '" + pCurrId + "'";
+//    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID = '" + pCurrId + "'";
+    sql = "select COMMUNICATION.COMMUNICATIONID from COMMUNICATION where COMMUNICATION.CONTACT_ID = '" + pCurrId + "'";
     ids = db.array(db.COLUMN, sql, alias, 0 , 1 * datetime.ONE_MINUTE);
     addIds(pRes, "Communications", ids);
 }
diff --git a/entity/Person_entity/recordcontainers/index/affectedIds.js b/entity/Person_entity/recordcontainers/index/affectedIds.js
index b4b39cb639..ed25062b17 100644
--- a/entity/Person_entity/recordcontainers/index/affectedIds.js
+++ b/entity/Person_entity/recordcontainers/index/affectedIds.js
@@ -13,27 +13,55 @@ infoContainer =  IndexsearchUtils.createAffectedInfoContainer(idValue, null, var
     ,function (){return vars.get("$local.oldvalues")}
     ,function (){return vars.get("$local.values")});
 
+// 
+//switch (tableName)
+//{
+//    case "PERSON":
+//        res = [idValue];
+//        break;    
+//    case "CONTACT":
+//        res = db.array(db.COLUMN, "select CONTACT.PERSON_ID from CONTACT where CONTACT.CONTACTID = '" + idValue + "'");
+//        break;
+//    case "ORGANISATION":
+//        res = db.array(db.COLUMN, "select CONTACT.PERSON_ID from CONTACT where CONTACT.PERSON_ID is not null and CONTACT.ORGANISATION_ID = '" + idValue + "'");
+//        break;
+//    case "ADDRESS":
+//        res = IndexsearchUtils.getAffectedIdValues("PERSON_ID", infoContainer, function (id){
+//            return db.array(db.COLUMN, ["select CONTACT.PERSON_ID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID is not null and ADDRESS.ADDRESSID = ?", [
+//                    [id, SqlUtils.getSingleColumnType("ADDRESS", "ADDRESSID")]
+//            ]]);
+//        });
+//        break;
+//    case "COMMUNICATION":
+//        res = IndexsearchUtils.getAffectedIdValues("PERSON_ID", infoContainer, function (id){
+//            return db.array(db.COLUMN, ["select CONTACT.PERSON_ID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID is not null and where COMMUNICATIONID = ?", [
+//                    [id, SqlUtils.getSingleColumnType("COMMUNICATION", "COMMUNICATIONID")]
+//            ]]);
+//        });
+//        break;
+//}
+
 switch (tableName)
 {
-    case "PERSON":
+    case "CONTACT":
         res = [idValue];
         break;    
-    case "CONTACT":
-        res = db.array(db.COLUMN, "select CONTACT.PERSON_ID from CONTACT where CONTACT.CONTACTID = '" + idValue + "'");
+    case "PERSON":
+        res = db.array(db.COLUMN, "select CONTACT.CONTACTID from CONTACT where CONTACT.PERSON_ID = '" + idValue + "'");
         break;
     case "ORGANISATION":
-        res = db.array(db.COLUMN, "select CONTACT.PERSON_ID from CONTACT where CONTACT.PERSON_ID is not null and CONTACT.ORGANISATION_ID = '" + idValue + "'");
+        res = db.array(db.COLUMN, "select CONTACT.CONTACTID from CONTACT where CONTACT.PERSON_ID is not null and CONTACT.ORGANISATION_ID = '" + idValue + "'");
         break;
     case "ADDRESS":
-        res = IndexsearchUtils.getAffectedIdValues("PERSON_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select CONTACT.PERSON_ID from ADDRESS left join CONTACT on CONTACT.CONTACTID = ADDRESS.CONTACT_ID where CONTACT.PERSON_ID is not null and ADDRESS.ADDRESSID = ?", [
+        res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
+            return db.array(db.COLUMN, ["select ADDRESS.CONTACT_ID from ADDRESS where ADDRESS.ADDRESSID = ?", [
                     [id, SqlUtils.getSingleColumnType("ADDRESS", "ADDRESSID")]
             ]]);
         });
         break;
     case "COMMUNICATION":
-        res = IndexsearchUtils.getAffectedIdValues("PERSON_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select CONTACT.PERSON_ID from COMMUNICATION left join CONTACT on CONTACT.CONTACTID = COMMUNICATION.CONTACT_ID where CONTACT.PERSON_ID is not null and where COMMUNICATIONID = ?", [
+        res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
+            return db.array(db.COLUMN, ["select COMMUNICATION.CONTACT_ID from COMMUNICATION where COMMUNICATIONID = ?", [
                     [id, SqlUtils.getSingleColumnType("COMMUNICATION", "COMMUNICATIONID")]
             ]]);
         });
diff --git a/entity/Person_entity/recordcontainers/index/query.js b/entity/Person_entity/recordcontainers/index/query.js
index fdf2d9995a..ece3dd3e34 100644
--- a/entity/Person_entity/recordcontainers/index/query.js
+++ b/entity/Person_entity/recordcontainers/index/query.js
@@ -13,7 +13,7 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select PERSON.PERSONID as uid "
+sqlQuery = 'select CONTACT.CONTACTID as "_uid_" '
     + "," + sqlHelper.concat(["PERSON.SALUTATION", "PERSON.FIRSTNAME", "PERSON.LASTNAME", "'|'", "ORGANISATION.NAME"]) 
     + ' as "_title_" '
     + "," + sqlHelper.concat([
@@ -21,7 +21,7 @@ sqlQuery = "select PERSON.PERSONID as uid "
             ,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"])
         ,sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"])
         ,sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"])
-        ], " | ") + " as description "
+        ], " | ") + ' as "_description_" '
     //additional indexed fields
     + ", PERSON.PERSONID "
     + ", PERSON.FIRSTNAME "
@@ -31,8 +31,8 @@ sqlQuery = "select PERSON.PERSONID as uid "
     + ", CONTACT.CONTACTID "
     + ", CONTACT.ORGANISATION_ID "
     + ", ORGANISATION.NAME "
-     + ", (" + CommUtil.getStandardSubSqlPhone() + ') as "STANDARD_PHONE_COMMUNICATION.value"'
-    + ", (" + CommUtil.getStandardSubSqlMail() + ') as "STANDARD_EMAIL_COMMUNICATION.value"'
+     + ", (" + CommUtil.getStandardSubSqlPhone() + ") as STANDARD_PHONE_COMMUNICATION"
+    + ", (" + CommUtil.getStandardSubSqlMail() + ") as STANDARD_EMAIL_COMMUNICATION"
     + " from PERSON "
     + " join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID "
     + " join ORGANISATION on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID "
diff --git a/entity/Product_entity/recordcontainers/index/query.js b/entity/Product_entity/recordcontainers/index/query.js
index 34a9a7a3be..0510962887 100644
--- a/entity/Product_entity/recordcontainers/index/query.js
+++ b/entity/Product_entity/recordcontainers/index/query.js
@@ -14,11 +14,11 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select PRODUCTID as uid, " 
+sqlQuery = 'select PRODUCTID as "_uid_", ' 
     + sqlHelper.concat(["PRODUCTCODE", "PRODUCTNAME"], " | ")
-    + " as title, " 
+    + ' as "_title_", ' 
     + KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.productGroupcode(), "GROUPCODEID")
-    + " as description" 
+    + ' as "_description_" ' 
     + ", PRODUCTCODE " 
     + " from PRODUCT "
     + queryCondition + " order by PRODUCTCODE ";
diff --git a/entity/Salesproject_entity/recordcontainers/index/query.js b/entity/Salesproject_entity/recordcontainers/index/query.js
index ae0bd2e48c..8d94ec07dd 100644
--- a/entity/Salesproject_entity/recordcontainers/index/query.js
+++ b/entity/Salesproject_entity/recordcontainers/index/query.js
@@ -15,13 +15,13 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 sqlHelper = new SqlMaskingUtils();
-sqlQuery = "select SALESPROJECTID as uid" 
-    + ", PROJECTTITLE as title, " 
+sqlQuery = 'select SALESPROJECTID as "_uid_"' 
+    + ', PROJECTTITLE as "_title_", ' 
     + sqlHelper.concat([
         "'" + translate.text("Status") + ":'",  KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesprojectState(), "STATE"),
         "'| " + translate.text("Phase") + ":'",  KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesprojectPhase(), "PHASE")
       ]) 
-    + " as description" 
+    + ' as "_description_" ' 
     + ", PROJECTCODE"
     + ", PROJECTTITLE"
     + ", STATE" 
-- 
GitLab