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/01 09:20:16 UTC

[unomi] 01/01: DMF-5757: merge all item indices into same index for reducing number of indices

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

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

commit 9a160c4eafe5e9aee42ca45679637fafd9827bbd
Author: Kevan <ke...@jahia.com>
AuthorDate: Wed Feb 1 10:20:01 2023 +0100

    DMF-5757: merge all item indices into same index for reducing number of indices
---
 .../actions/listener/GroovyActionListener.java     |   9 --
 .../META-INF/cxs/mappings/groovyAction.json        |  28 ----
 .../unomi/schema/impl/SchemaServiceImpl.java       |   9 --
 .../ElasticSearchPersistenceServiceImpl.java       |  87 +++++++++++--
 .../META-INF/cxs/mappings/actionType.json          |  20 ---
 .../resources/META-INF/cxs/mappings/campaign.json  |  51 --------
 .../META-INF/cxs/mappings/campaignevent.json       |  44 -------
 .../META-INF/cxs/mappings/conditionType.json       |  26 ----
 .../META-INF/cxs/mappings/exportConfig.json        |  20 ---
 .../main/resources/META-INF/cxs/mappings/goal.json |  46 -------
 .../META-INF/cxs/mappings/importConfig.json        |  20 ---
 .../main/resources/META-INF/cxs/mappings/item.json | 141 +++++++++++++++++++++
 .../META-INF/cxs/mappings/jsonschema.json          |  25 ----
 .../resources/META-INF/cxs/mappings/patch.json     |  38 ------
 .../resources/META-INF/cxs/mappings/persona.json   |  38 ------
 .../META-INF/cxs/mappings/personaSession.json      |  41 ------
 .../META-INF/cxs/mappings/propertyType.json        |  61 ---------
 .../main/resources/META-INF/cxs/mappings/rule.json |  62 ---------
 .../resources/META-INF/cxs/mappings/rulestats.json |  20 ---
 .../resources/META-INF/cxs/mappings/scope.json     |  22 ----
 .../resources/META-INF/cxs/mappings/scoring.json   |  46 -------
 .../resources/META-INF/cxs/mappings/segment.json   |  42 ------
 .../resources/META-INF/cxs/mappings/topic.json     |  20 ---
 23 files changed, 217 insertions(+), 699 deletions(-)

diff --git a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/listener/GroovyActionListener.java b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/listener/GroovyActionListener.java
index 2ac3e37c4..86baae6b1 100644
--- a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/listener/GroovyActionListener.java
+++ b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/listener/GroovyActionListener.java
@@ -62,7 +62,6 @@ public class GroovyActionListener implements SynchronousBundleListener {
 
     public void postConstruct() {
         logger.debug("postConstruct {}", bundleContext.getBundle());
-        createIndex();
         loadGroovyActions(bundleContext);
         for (Bundle bundle : bundleContext.getBundles()) {
             if (bundle.getBundleContext() != null && bundle.getBundleId() != bundleContext.getBundle().getBundleId()) {
@@ -107,14 +106,6 @@ public class GroovyActionListener implements SynchronousBundleListener {
         }
     }
 
-    public void createIndex() {
-        if (persistenceService.createIndex(GroovyAction.ITEM_TYPE)) {
-            logger.info("GroovyAction index created");
-        } else {
-            logger.info("GroovyAction index already exists");
-        }
-    }
-
     private void addGroovyAction(URL groovyActionURL) {
         try {
             groovyActionsService.save(FilenameUtils.getName(groovyActionURL.getPath()).replace(".groovy", ""),
diff --git a/extensions/groovy-actions/services/src/main/resources/META-INF/cxs/mappings/groovyAction.json b/extensions/groovy-actions/services/src/main/resources/META-INF/cxs/mappings/groovyAction.json
deleted file mode 100644
index 6cd8d3ff8..000000000
--- a/extensions/groovy-actions/services/src/main/resources/META-INF/cxs/mappings/groovyAction.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "name": {
-      "type": "text"
-    },
-    "script": {
-      "type": "text"
-    }
-  }
-}
\ No newline at end of file
diff --git a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
index ebc431f7f..44ff90f7b 100644
--- a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
+++ b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
@@ -296,14 +296,6 @@ public class SchemaServiceImpl implements SchemaService {
         return schema;
     }
 
-    private void initPersistenceIndex() {
-        if (persistenceService.createIndex(JsonSchemaWrapper.ITEM_TYPE)) {
-            logger.info("{} index created", JsonSchemaWrapper.ITEM_TYPE);
-        } else {
-            logger.info("{} index already exists", JsonSchemaWrapper.ITEM_TYPE);
-        }
-    }
-
     private void initTimers() {
         TimerTask task = new TimerTask() {
             @Override
@@ -345,7 +337,6 @@ public class SchemaServiceImpl implements SchemaService {
 
     public void init() {
         scheduler = Executors.newSingleThreadScheduledExecutor();
-        initPersistenceIndex();
         initJsonSchemaFactory();
         initTimers();
         logger.info("Schema service initialized.");
diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 8de571eb4..61e852275 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -168,6 +168,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@@ -261,6 +262,37 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
 
     private Map<String, Map<String, Map<String, Object>>> knownMappings = new HashMap<>();
 
+    private static Map<String, String> itemTypeIndexNameMap = new ConcurrentHashMap<>();
+    static {
+        // metadata items
+        itemTypeIndexNameMap.put("actionType", "item");
+        itemTypeIndexNameMap.put("campaign", "item");
+        itemTypeIndexNameMap.put("campaignevent", "item");
+        itemTypeIndexNameMap.put("goal", "item");
+        itemTypeIndexNameMap.put("userList", "item");
+        itemTypeIndexNameMap.put("propertyType", "item");
+        itemTypeIndexNameMap.put("scope", "item");
+        itemTypeIndexNameMap.put("conditionType", "item");
+        itemTypeIndexNameMap.put("rule", "item");
+        itemTypeIndexNameMap.put("scoring", "item");
+        itemTypeIndexNameMap.put("segment", "item");
+        itemTypeIndexNameMap.put("groovyAction", "item");
+
+        // direct item implems
+        itemTypeIndexNameMap.put("topic", "item");
+        itemTypeIndexNameMap.put("patch", "item");
+        itemTypeIndexNameMap.put("jsonSchema", "item");
+        itemTypeIndexNameMap.put("importConfig", "item");
+        itemTypeIndexNameMap.put("exportConfig", "item");
+        itemTypeIndexNameMap.put("rulestats", "item");
+
+        itemTypeIndexNameMap.put("profile", "profile");
+        itemTypeIndexNameMap.put("persona", "profile");
+
+        itemTypeIndexNameMap.put("session", "session");
+        itemTypeIndexNameMap.put("personaSession", "session");
+    }
+
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
@@ -858,7 +890,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                         GetResponse response = client.get(getRequest, RequestOptions.DEFAULT);
                         if (response.isExists()) {
                             String sourceAsString = response.getSourceAsString();
-                            final T value = ESCustomObjectMapper.getObjectMapper().readValue(sourceAsString, clazz);
+                            -final T value = ESCustomObjectMapper.getObjectMapper().readValue(sourceAsString, clazz);
                             setMetadata(value, response.getId(), response.getVersion(), response.getSeqNo(), response.getPrimaryTerm(), response.getIndex());
                             return value;
                         } else {
@@ -1111,13 +1143,14 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                     for (int i = 0; i < scripts.length; i++) {
                         RefreshRequest refreshRequest = new RefreshRequest(index);
                         client.indices().refresh(refreshRequest, RequestOptions.DEFAULT);
+                        QueryBuilder queryBuilder = conditionESQueryBuilderDispatcher.buildFilter(conditions[i]);
 
                         UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(index);
                         updateByQueryRequest.setConflicts("proceed");
                         updateByQueryRequest.setMaxRetries(1000);
                         updateByQueryRequest.setSlices(2);
                         updateByQueryRequest.setScript(scripts[i]);
-                        updateByQueryRequest.setQuery(conditionESQueryBuilderDispatcher.buildFilter(conditions[i]));
+                        updateByQueryRequest.setQuery(isItemTypeSharingIndex(itemType) ? wrapWithItemTypeQuery(itemType, queryBuilder) : queryBuilder);
 
                         BulkByScrollResponse response = client.updateByQuery(updateByQueryRequest, RequestOptions.DEFAULT);
 
@@ -1276,8 +1309,9 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
             protected Boolean execute(Object... args) throws Exception {
                 try {
                     String itemType = Item.getItemType(clazz);
+                    QueryBuilder queryBuilder = conditionESQueryBuilderDispatcher.getQueryBuilder(query);
                     final DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(getIndexNameForQuery(itemType))
-                            .setQuery(conditionESQueryBuilderDispatcher.getQueryBuilder(query))
+                            .setQuery(isItemTypeSharingIndex(itemType) ? wrapWithItemTypeQuery(itemType, queryBuilder) : queryBuilder)
                             // Setting slices to auto will let Elasticsearch choose the number of slices to use.
                             // This setting will use one slice per shard, up to a certain limit.
                             // The delete request will be more efficient and faster than no slicing.
@@ -1915,7 +1949,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
 
                 CountRequest countRequest = new CountRequest(getIndexNameForQuery(itemType));
                 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
-                searchSourceBuilder.query(filter);
+                searchSourceBuilder.query(isItemTypeSharingIndex(itemType) ? wrapWithItemTypeQuery(itemType, filter) : filter);
                 countRequest.source(searchSourceBuilder);
                 CountResponse response = client.count(countRequest, RequestOptions.DEFAULT);
                 return response.getCount();
@@ -1950,7 +1984,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                     SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder()
                             .fetchSource(true)
                             .seqNoAndPrimaryTerm(true)
-                            .query(query)
+                            .query(isItemTypeSharingIndex(itemType) ? wrapWithItemTypeQuery(itemType, query) : query)
                             .size(size < 0 ? defaultQueryLimit : size)
                             .from(offset);
                     if (scrollTimeValidity != null) {
@@ -2171,7 +2205,9 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                 SearchRequest searchRequest = new SearchRequest(getIndexNameForQuery(itemType));
                 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
                 searchSourceBuilder.size(0);
-                searchSourceBuilder.query(QueryBuilders.matchAllQuery());
+                MatchAllQueryBuilder matchAll = QueryBuilders.matchAllQuery();
+                boolean isItemTypeSharingIndex = isItemTypeSharingIndex(itemType);
+                searchSourceBuilder.query(isItemTypeSharingIndex ? getItemTypeQueryBuilder(itemType) : matchAll);
                 List<AggregationBuilder> lastAggregation = new ArrayList<AggregationBuilder>();
 
                 if (aggregate != null) {
@@ -2252,11 +2288,15 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                     }
 
                     if (filter != null) {
-                        searchSourceBuilder.query(conditionESQueryBuilderDispatcher.buildFilter(filter));
+                        searchSourceBuilder.query(isItemTypeSharingIndex ?
+                                wrapWithItemTypeQuery(itemType, conditionESQueryBuilderDispatcher.buildFilter(filter)) :
+                                conditionESQueryBuilderDispatcher.buildFilter(filter));
                     }
                 } else {
                     if (filter != null) {
-                        AggregationBuilder filterAggregation = AggregationBuilders.filter("filter", conditionESQueryBuilderDispatcher.buildFilter(filter));
+                        AggregationBuilder filterAggregation = AggregationBuilders.filter("filter", isItemTypeSharingIndex ?
+                                wrapWithItemTypeQuery(itemType, conditionESQueryBuilderDispatcher.buildFilter(filter)) :
+                                conditionESQueryBuilderDispatcher.buildFilter(filter));
                         for (AggregationBuilder aggregationBuilder : lastAggregation) {
                             filterAggregation.subAggregation(aggregationBuilder);
                         }
@@ -2477,7 +2517,8 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                 SearchRequest searchRequest = new SearchRequest(getIndexNameForQuery(itemType));
                 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder()
                         .size(0)
-                        .query(QueryBuilders.matchAllQuery());
+                        .query(isItemTypeSharingIndex(itemType) ? getItemTypeQueryBuilder(itemType) : QueryBuilders.matchAllQuery());
+
                 AggregationBuilder filterAggregation = AggregationBuilders.filter("metrics", conditionESQueryBuilderDispatcher.buildFilter(condition));
 
                 if (metrics != null) {
@@ -2611,12 +2652,36 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
         return rolloverIndices.contains(itemType) ? getRolloverIndexForQuery(itemType) : getIndex(itemType);
     }
 
+<<<<<<< Updated upstream
     private String getRolloverIndexForQuery(String itemType) {
         return indexPrefix + "-" + itemType.toLowerCase() + "-*";
+=======
+    private String getMonthlyIndexForQuery(String itemType) {
+        return indexPrefix + "-" + getIndexNameForItemType(itemType) + "-*";
+>>>>>>> Stashed changes
+    }
+
+    private String getIndex(String itemType) {
+        return (indexPrefix + "-" + getIndexNameForItemType(itemType)).toLowerCase();
+    }
+
+    private String getIndexNameForItemType(String itemType) {
+        return itemTypeIndexNameMap.getOrDefault(itemType, itemType);
+    }
+
+    private QueryBuilder wrapWithItemTypeQuery(String itemType, QueryBuilder originalQuery) {
+        BoolQueryBuilder wrappedQuery = QueryBuilders.boolQuery();
+        wrappedQuery.must(getItemTypeQueryBuilder(itemType));
+        wrappedQuery.must(originalQuery);
+        return wrappedQuery;
+    }
+
+    private QueryBuilder getItemTypeQueryBuilder(String itemType) {
+        return QueryBuilders.termQuery("itemType", itemType);
     }
 
-    private String getIndex(String indexItemTypePart) {
-        return (indexPrefix + "-" + indexItemTypePart).toLowerCase();
+    private boolean isItemTypeSharingIndex(String itemType) {
+        return itemTypeIndexNameMap.containsKey(itemType);
     }
 
     private WriteRequest.RefreshPolicy getRefreshPolicy(String itemType) {
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/actionType.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/actionType.json
deleted file mode 100644
index e1ac5f8d4..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/actionType.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json
deleted file mode 100644
index 9cfabbb94..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json
deleted file mode 100644
index 7d6a564d0..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "cost": {
-      "type": "double"
-    },
-    "eventDate": {
-      "type": "date"
-    },
-    "metadata": {
-      "properties": {
-        "enabled": {
-          "type": "boolean"
-        },
-        "hidden": {
-          "type": "boolean"
-        },
-        "missingPlugins": {
-          "type": "boolean"
-        },
-        "readOnly": {
-          "type": "boolean"
-        }
-      }
-    }
-  }
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/conditionType.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/conditionType.json
deleted file mode 100644
index 61919135a..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/conditionType.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/exportConfig.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/exportConfig.json
deleted file mode 100644
index e1ac5f8d4..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/exportConfig.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json
deleted file mode 100644
index c1f264951..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/importConfig.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/importConfig.json
deleted file mode 100644
index e1ac5f8d4..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/importConfig.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/item.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/item.json
new file mode 100644
index 000000000..ca5a7a397
--- /dev/null
+++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/item.json
@@ -0,0 +1,141 @@
+{
+  "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
+    },
+    "parentCondition":  {
+      "type": "object",
+      "enabled": false
+    },
+    "startEvent": {
+      "type": "object",
+      "enabled": false
+    },
+    "targetEvent": {
+      "type": "object",
+      "enabled": false
+    },
+    "eventDate": {
+      "type": "date"
+    },
+    "multivalued": {
+      "type": "boolean"
+    },
+    "numericRanges": {
+      "properties": {
+        "from": {
+          "type": "double"
+        },
+        "to": {
+          "type": "double"
+        }
+      }
+    },
+    "protected": {
+      "type": "boolean"
+    },
+    "rank": {
+      "type": "double"
+    },
+    "dateRanges": {
+      "properties": {
+      }
+    },
+    "priority": {
+      "type": "long"
+    },
+    "raiseEventOnlyOnceForProfile": {
+      "type": "boolean"
+    },
+    "raiseEventOnlyOnceForSession": {
+      "type": "boolean"
+    },
+    "raiseEventOnlyOnce": {
+      "type": "boolean"
+    },
+    "condition": {
+      "type": "object",
+      "enabled": false
+    },
+    "actions": {
+      "properties": {
+        "parameterValues": {
+          "type": "object",
+          "enabled": false
+        }
+      }
+    },
+    "elements": {
+      "properties": {
+        "condition": {
+          "type": "object",
+          "enabled": false
+        }
+      }
+    },
+
+    "patchedItemId": {
+      "type": "text"
+    },
+    "patchedItemType": {
+      "type": "text"
+    },
+    "operation": {
+      "type": "text"
+    },
+    "data": {
+      "type": "object",
+      "enabled": false
+    },
+    "lastApplication": {
+      "type": "date"
+    },
+    "schema": {
+      "type": "text"
+    }
+  }
+}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/jsonschema.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/jsonschema.json
deleted file mode 100644
index 896e1be21..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/jsonschema.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "schema": {
-      "type": "text"
-    }
-  }
-}
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/patch.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/patch.json
deleted file mode 100644
index e622845c4..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/patch.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json
deleted file mode 100644
index d0142451f..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "properties": {
-      "properties": {
-        "firstVisit": {
-          "type": "date"
-        },
-        "lastVisit": {
-          "type": "date"
-        },
-        "previousVisit": {
-          "type": "date"
-        },
-        "nbOfVisits": {
-          "type": "long"
-        }
-      }
-    }
-  }
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json
deleted file mode 100644
index c635e0285..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "duration": {
-      "type": "long"
-    },
-    "timeStamp": {
-      "type": "date"
-    },
-    "lastEventDate": {
-      "type": "date"
-    },
-    "properties": {
-      "properties": {
-        "location": {
-          "type": "geo_point"
-        }
-      }
-    },
-    "size": {
-      "type": "long"
-    }
-  }
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json
deleted file mode 100644
index 3898c8c68..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-    "dateRanges": {
-      "properties": {
-      }
-    },
-    "metadata": {
-      "properties": {
-        "enabled": {
-          "type": "boolean"
-        },
-        "hidden": {
-          "type": "boolean"
-        },
-        "missingPlugins": {
-          "type": "boolean"
-        },
-        "readOnly": {
-          "type": "boolean"
-        }
-      }
-    },
-    "multivalued": {
-      "type": "boolean"
-    },
-    "numericRanges": {
-      "properties": {
-        "from": {
-          "type": "double"
-        },
-        "to": {
-          "type": "double"
-        }
-      }
-    },
-    "protected": {
-      "type": "boolean"
-    },
-    "rank": {
-      "type": "double"
-    }
-  }
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json
deleted file mode 100644
index d11cc551e..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rulestats.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rulestats.json
deleted file mode 100644
index e1ac5f8d4..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rulestats.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scope.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scope.json
deleted file mode 100644
index 27fa2b384..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scope.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ],
-  "properties": {
-  }
-}
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scoring.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scoring.json
deleted file mode 100644
index e313cdfaf..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/scoring.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
-  "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/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json
deleted file mode 100644
index 676a0a9ee..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
-  "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
-    }
-  }
-}
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/topic.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/topic.json
deleted file mode 100644
index d2d90cb94..000000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/topic.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "dynamic_templates": [
-    {
-      "all": {
-        "match": "*",
-        "match_mapping_type": "string",
-        "mapping": {
-          "type": "text",
-          "analyzer": "folding",
-          "fields": {
-            "keyword": {
-              "type": "keyword",
-              "ignore_above": 256
-            }
-          }
-        }
-      }
-    }
-  ]
-}