You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2019/12/07 20:45:41 UTC

[unomi] branch UNOMI-225-fix-migration-mappings updated: UNOMI-225 ElasticSearch 7 fix issues with mappings when migrating Fix issue with properties merging that was not properly replacing all the configuration for a mapping field type.

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

shuber pushed a commit to branch UNOMI-225-fix-migration-mappings
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/UNOMI-225-fix-migration-mappings by this push:
     new efc9af5  UNOMI-225 ElasticSearch 7 fix issues with mappings when migrating Fix issue with properties merging that was not properly replacing all the configuration for a mapping field type.
efc9af5 is described below

commit efc9af5089c8729c95452a637597fe729a54cead
Author: Serge Huber <sh...@apache.org>
AuthorDate: Sat Dec 7 21:45:34 2019 +0100

    UNOMI-225 ElasticSearch 7 fix issues with mappings when migrating
    Fix issue with properties merging that was not properly replacing all the configuration for a mapping field type.
    
    Signed-off-by: Serge Huber <sh...@apache.org>
---
 .../org/apache/unomi/shell/migration/impl/MigrationTo150.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo150.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo150.java
index ecdf39b..28f1e60 100644
--- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo150.java
+++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo150.java
@@ -276,8 +276,13 @@ public class MigrationTo150 implements Migration {
                 result.put(oldPropertyName, oldProperties.get(oldPropertyName));
                 continue;
             }
-            if (oldProperties.get(oldPropertyName) instanceof JSONObject && newProperties.get(oldPropertyName) instanceof JSONObject) {
-                result.put(oldPropertyName, getMergedPropertyMappings(oldProperties.getJSONObject(oldPropertyName), newProperties.getJSONObject(oldPropertyName)));
+            JSONObject oldProperty = oldProperties.getJSONObject(oldPropertyName);
+            JSONObject newProperty = newProperties.getJSONObject(oldPropertyName);
+            if (oldProperty.has("properties") && newProperty.has("properties")) {
+                // we are in the case of an object, we merge merge deeper
+                JSONObject newObjectMapping = new JSONObject(newProperty.toString());
+                newObjectMapping.put("properties", getMergedPropertyMappings(oldProperty.getJSONObject("properties"), newProperty.getJSONObject("properties")));
+                result.put(oldPropertyName, newObjectMapping);
             } else {
                 // in all other cases we copy the new value.
                 result.put(oldPropertyName, newProperties.get(oldPropertyName));