You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2023/02/24 09:36:05 UTC

[unomi] branch reduceIndicesItems2 updated: UNOMI-736: Fix old migration on 2.0.0 due to mappings removed from core persistence

This is an automated email from the ASF dual-hosted git repository.

jkevan pushed a commit to branch reduceIndicesItems2
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/reduceIndicesItems2 by this push:
     new f2bca2ba1 UNOMI-736: Fix old migration on  2.0.0 due to mappings removed from core persistence
f2bca2ba1 is described below

commit f2bca2ba17444684a45ef84253ecf34171282258
Author: Kevan <ke...@jahia.com>
AuthorDate: Fri Feb 24 10:35:56 2023 +0100

    UNOMI-736: Fix old migration on  2.0.0 due to mappings removed from core persistence
---
 .../migrate-2.0.0-05-globalReindex.groovy          |  2 +-
 .../cxs/migration/migrate-2.0.0-20-scopes.groovy   |  2 +-
 .../requestBody/2.0.0/mappings/campaign.json       | 51 ++++++++++++++++++
 .../requestBody/2.0.0/mappings/conditionType.json  | 26 +++++++++
 .../resources/requestBody/2.0.0/mappings/goal.json | 46 ++++++++++++++++
 .../requestBody/2.0.0/mappings/patch.json          | 38 +++++++++++++
 .../resources/requestBody/2.0.0/mappings/rule.json | 62 ++++++++++++++++++++++
 .../requestBody/2.0.0/mappings/scope.json          | 22 ++++++++
 .../requestBody/2.0.0/mappings/scoring.json        | 46 ++++++++++++++++
 .../requestBody/2.0.0/mappings/segment.json        | 42 +++++++++++++++
 10 files changed, 335 insertions(+), 2 deletions(-)

diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-05-globalReindex.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-05-globalReindex.groovy
index dd841ff11..3d013b1e4 100644
--- a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-05-globalReindex.groovy
+++ b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-05-globalReindex.groovy
@@ -25,7 +25,7 @@ String indexPrefix = context.getConfigString("indexPrefix")
 String baseSettings = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/base_index_mapping.json")
 String[] indicesToReindex = ["segment", "scoring", "campaign", "conditionType", "goal", "patch", "rule"];
 indicesToReindex.each { indexToReindex ->
-    String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "${indexToReindex}.json")
+    String mapping = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/mappings/${indexToReindex}.json")
     String newIndexSettings = MigrationUtils.buildIndexCreationRequest(baseSettings, mapping, context, false)
     MigrationUtils.reIndex(context.getHttpClient(), bundleContext, esAddress, "${indexPrefix}-${indexToReindex.toLowerCase()}", newIndexSettings, null, context)
 }
diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-20-scopes.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-20-scopes.groovy
index d9aa5f889..1f63d1b82 100644
--- a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-20-scopes.groovy
+++ b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-20-scopes.groovy
@@ -32,7 +32,7 @@ String scopeIndex = indexPrefix + "-scope"
 context.performMigrationStep("2.0.0-create-scope-index", () -> {
     if (!MigrationUtils.indexExists(context.getHttpClient(), esAddress, scopeIndex)) {
         String baseRequest = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/base_index_mapping.json")
-        String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "scope.json")
+        String mapping = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/mappings/scope.json")
         String newIndexSettings = MigrationUtils.buildIndexCreationRequest(baseRequest, mapping, context, false)
         HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/" + scopeIndex, newIndexSettings, null)
     }
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/campaign.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/campaign.json
new file mode 100644
index 000000000..9cfabbb94
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/campaign.json
@@ -0,0 +1,51 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "cost": {
+      "type": "double"
+    },
+    "startDate": {
+      "type": "date"
+    },
+    "endDate": {
+      "type": "date"
+    },
+    "metadata": {
+      "properties": {
+        "enabled": {
+          "type": "boolean"
+        },
+        "hidden": {
+          "type": "boolean"
+        },
+        "missingPlugins": {
+          "type": "boolean"
+        },
+        "readOnly": {
+          "type": "boolean"
+        }
+      }
+    },
+    "entryCondition":  {
+      "type": "object",
+      "enabled": false
+    }
+  }
+}
\ No newline at end of file
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/conditionType.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/conditionType.json
new file mode 100644
index 000000000..61919135a
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/conditionType.json
@@ -0,0 +1,26 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "parentCondition":  {
+      "type": "object",
+      "enabled": false
+    }
+  }
+}
\ No newline at end of file
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/goal.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/goal.json
new file mode 100644
index 000000000..c1f264951
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/goal.json
@@ -0,0 +1,46 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "metadata": {
+      "properties": {
+        "enabled": {
+          "type": "boolean"
+        },
+        "hidden": {
+          "type": "boolean"
+        },
+        "missingPlugins": {
+          "type": "boolean"
+        },
+        "readOnly": {
+          "type": "boolean"
+        }
+      }
+    },
+    "startEvent": {
+      "type": "object",
+      "enabled": false
+    },
+    "targetEvent": {
+      "type": "object",
+      "enabled": false
+    }
+  }
+}
\ No newline at end of file
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/patch.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/patch.json
new file mode 100644
index 000000000..e622845c4
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/patch.json
@@ -0,0 +1,38 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "patchedItemId": {
+      "type": "text"
+    },
+    "patchedItemType": {
+      "type": "text"
+    },
+    "operation": {
+      "type": "text"
+    },
+    "data": {
+      "type": "object",
+      "enabled": false
+    },
+    "lastApplication": {
+      "type": "date"
+    }
+  }
+}
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/rule.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/rule.json
new file mode 100644
index 000000000..d11cc551e
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/rule.json
@@ -0,0 +1,62 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "metadata": {
+      "properties": {
+        "enabled": {
+          "type": "boolean"
+        },
+        "hidden": {
+          "type": "boolean"
+        },
+        "missingPlugins": {
+          "type": "boolean"
+        },
+        "readOnly": {
+          "type": "boolean"
+        }
+      }
+    },
+    "priority": {
+      "type": "long"
+    },
+    "raiseEventOnlyOnceForProfile": {
+      "type": "boolean"
+    },
+    "raiseEventOnlyOnceForSession": {
+      "type": "boolean"
+    },
+    "raiseEventOnlyOnce": {
+      "type": "boolean"
+    },
+    "condition": {
+      "type": "object",
+      "enabled": false
+    },
+    "actions": {
+      "properties": {
+        "parameterValues": {
+          "type": "object",
+          "enabled": false
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scope.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scope.json
new file mode 100644
index 000000000..27fa2b384
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scope.json
@@ -0,0 +1,22 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+  }
+}
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scoring.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scoring.json
new file mode 100644
index 000000000..e313cdfaf
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/scoring.json
@@ -0,0 +1,46 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "metadata": {
+      "properties": {
+        "enabled": {
+          "type": "boolean"
+        },
+        "hidden": {
+          "type": "boolean"
+        },
+        "missingPlugins": {
+          "type": "boolean"
+        },
+        "readOnly": {
+          "type": "boolean"
+        }
+      }
+    },
+    "elements": {
+      "properties": {
+        "condition": {
+          "type": "object",
+          "enabled": false
+        }
+      }
+    }
+  }
+}
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/segment.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/segment.json
new file mode 100644
index 000000000..676a0a9ee
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/mappings/segment.json
@@ -0,0 +1,42 @@
+{
+  "dynamic_templates": [
+    {
+      "all": {
+        "match": "*",
+        "match_mapping_type": "string",
+        "mapping": {
+          "type": "text",
+          "analyzer": "folding",
+          "fields": {
+            "keyword": {
+              "type": "keyword",
+              "ignore_above": 256
+            }
+          }
+        }
+      }
+    }
+  ],
+  "properties": {
+    "metadata": {
+      "properties": {
+        "enabled": {
+          "type": "boolean"
+        },
+        "hidden": {
+          "type": "boolean"
+        },
+        "missingPlugins": {
+          "type": "boolean"
+        },
+        "readOnly": {
+          "type": "boolean"
+        }
+      }
+    },
+    "condition": {
+      "type": "object",
+      "enabled": false
+    }
+  }
+}