You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by js...@apache.org on 2022/07/11 13:55:07 UTC

[unomi] branch UNOMI-603-migration-profiles created (now b2932f2ca)

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

jsinovassinnaik pushed a change to branch UNOMI-603-migration-profiles
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at b2932f2ca UNOMI-603 : create migration for profile and fix issues

This branch includes the following new commits:

     new b2932f2ca UNOMI-603 : create migration for profile and fix issues

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI-603 : create migration for profile and fix issues

Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jsinovassinnaik pushed a commit to branch UNOMI-603-migration-profiles
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit b2932f2ca12178dce0ff17d0238dcd44c8ff4b28
Author: jsinovassin <js...@jahia.com>
AuthorDate: Mon Jul 11 15:54:55 2022 +0200

    UNOMI-603 : create migration for profile and fix issues
---
 .../unomi/shell/migration/impl/MigrationTo200.java |  3 +-
 .../migrate-2.0.0-03-profileReindex.groovy         | 22 +++++++
 .../resources/requestBody/2.0.0/profile_index.json | 76 ++++++++++++++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo200.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo200.java
index 6b94e16b7..edd92562e 100644
--- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo200.java
+++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo200.java
@@ -243,7 +243,8 @@ public class MigrationTo200 implements Migration {
 
             while (true) {
                 JSONObject responseAsJson = getResponseAsJSON(response);
-                String scrollId = responseAsJson.getString("_scroll_id");
+
+                String scrollId = responseAsJson.has("_scroll_id") ? responseAsJson.getString("_scroll_id"): null;
                 JSONArray hits = getProfileHits(responseAsJson);
 
                 if (hits.length() == 0) {
diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-03-profileReindex.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-03-profileReindex.groovy
new file mode 100644
index 000000000..691da0d93
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-03-profileReindex.groovy
@@ -0,0 +1,22 @@
+import org.apache.unomi.shell.migration.utils.MigrationUtils
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+String newIndexSettings = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/profile_index.json");
+MigrationUtils.reIndex(httpClient, bundleContext, migrationConfig.get("esAddress"), migrationConfig.get("indexPrefix") + "-profile",
+        newIndexSettings)
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.0.0/profile_index.json b/tools/shell-commands/src/main/resources/requestBody/2.0.0/profile_index.json
new file mode 100644
index 000000000..0808aa03e
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.0.0/profile_index.json
@@ -0,0 +1,76 @@
+{
+    "settings": {
+        "index": {
+            "number_of_shards": #numberOfShards,
+            "number_of_replicas": #numberOfReplicas,
+            "mapping.total_fields.limit": #mappingTotalFieldsLimit,
+            "max_docvalue_fields_search": #maxDocValueFieldsSearch
+        },
+        "analysis": {
+            "analyzer": {
+                "folding": {
+                    "type": "custom",
+                    "tokenizer": "keyword",
+                    "filter": [
+                        "lowercase",
+                        "asciifolding"
+                    ]
+                }
+            }
+        }
+    },
+    "mappings": {
+        "dynamic_templates": [
+            {
+                "all": {
+                    "match": "*",
+                    "match_mapping_type": "string",
+                    "mapping": {
+                        "type": "text",
+                        "analyzer": "folding",
+                        "fields": {
+                            "keyword": {
+                                "type": "keyword",
+                                "ignore_above": 256
+                            }
+                        }
+                    }
+                }
+            }
+        ],
+        "properties": {
+            "properties": {
+                "properties": {
+                    "age": {
+                        "type": "long"
+                    },
+                    "firstVisit": {
+                        "type": "date"
+                    },
+                    "lastVisit": {
+                        "type": "date"
+                    },
+                    "previousVisit": {
+                        "type": "date"
+                    },
+                    "nbOfVisits": {
+                        "type": "long"
+                    },
+                    "interests": {
+                        "type": "nested"
+                    }
+                }
+            },
+            "consents": {
+                "properties": {
+                    "statusDate": {
+                        "type": "date"
+                    },
+                    "revokeDate": {
+                        "type": "date"
+                    }
+                }
+            }
+        }
+    }
+}