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/08/02 10:22:00 UTC
[unomi] 01/01: UNOMI-637 : do not create mapping for property type if not necessary
This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a commit to branch UNOMI-637-fix-mapping-creation
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit e7c7b62b442a4f2c98c266688752336d2f96a8d8
Author: jsinovassin <js...@jahia.com>
AuthorDate: Tue Aug 2 12:21:39 2022 +0200
UNOMI-637 : do not create mapping for property type if not necessary
---
.../elasticsearch/ElasticSearchPersistenceServiceImpl.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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 cd5183232..fcc95f791 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
@@ -1444,7 +1444,10 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
}
Map<String, Object> subMappings = mappings.computeIfAbsent("properties", k -> new HashMap<>());
Map<String, Object> subSubMappings = (Map<String, Object>) subMappings.computeIfAbsent("properties", k -> new HashMap<>());
- mergePropertiesMapping(subSubMappings, createPropertyMapping(property));
+ Map<String, Object> propertyMapping = createPropertyMapping(property);
+ if (propertyMapping != null) {
+ mergePropertiesMapping(subSubMappings, propertyMapping);
+ }
Map<String, Object> mappingsWrapper = new HashMap<>();
mappingsWrapper.put("properties", mappings);
@@ -1479,12 +1482,15 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
if ("set".equals(property.getValueTypeId())) {
Map<String, Object> childProperties = new HashMap<>();
property.getChildPropertyTypes().forEach(childType -> {
- mergePropertiesMapping(childProperties, createPropertyMapping(childType));
+ Map<String, Object> propertyMapping = createPropertyMapping(childType);
+ if (propertyMapping != null) {
+ mergePropertiesMapping(childProperties, propertyMapping);
+ }
});
definition.put("properties", childProperties);
}
- return Collections.singletonMap(property.getItemId(), definition);
+ return !definition.isEmpty() ? Collections.singletonMap(property.getItemId(), definition) : null;
}
private String convertValueTypeToESType(String valueTypeId) {