Skip to content
Snippets Groups Projects
Commit fa950659 authored by Neelesh Thakur's avatar Neelesh Thakur Committed by David Diederich
Browse files

Merge branch 'nested-text-array' into 'master'

correctly resolve mapping for text array inside nested array object

See merge request !358

(cherry picked from commit a32377ed)

9fb99c26 correctly resolve mapping for text array inside nested array object
cc9fe5ad correctly resolve mapping for text array inside nested array object
186067cf NOTICE
95a1c11d rebase
a3854473 Merge remote-tracking branch 'origin/master' into nested-text-array
parent b7aa0861
No related branches found
No related tags found
1 merge request!369Cherry-pick 'correctly resolve mapping for text array inside nested array object' into release/0.16
Pipeline #129923 failed
......@@ -14,10 +14,6 @@
package org.opengroup.osdu.indexer.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.opengroup.osdu.core.common.Constants;
import org.opengroup.osdu.core.common.model.entitlements.AclRole;
......@@ -26,6 +22,11 @@ import org.opengroup.osdu.core.common.model.indexer.Records;
import org.opengroup.osdu.core.common.model.indexer.StorageType;
import org.opengroup.osdu.core.common.model.search.RecordMetaAttribute;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TypeMapper {
private static final Map<String, String> storageToIndexerType = new HashMap<>();
......@@ -80,7 +81,7 @@ public class TypeMapper {
//TODO temporary fix for https://community.opengroup.org/osdu/platform/system/indexer-service/-/issues/1
storageToIndexerType.put(STORAGE_TYPE_OBJECTS, ElasticType.OBJECT.getValue());
storageToIndexerType.put(STORAGE_TYPE_NESTED, ElasticType.NESTED.getValue());
storageToIndexerType.put(STORAGE_TYPE_FLATTENED,ElasticType.FLATTENED.getValue());
storageToIndexerType.put(STORAGE_TYPE_FLATTENED, ElasticType.FLATTENED.getValue());
}
public static String getIndexerType(String storageType, String defaultType) {
......@@ -130,8 +131,10 @@ public class TypeMapper {
for (Map.Entry<String, Object> entry : propertiesMap.entrySet()) {
if (isMap(entry.getValue())) {
entry.setValue(getDataAttributeIndexerMapping(entry.getValue()));
} else if(ElasticType.TEXT.getValue().equalsIgnoreCase(String.valueOf(entry.getValue()))) {
} else if (ElasticType.TEXT.getValue().equalsIgnoreCase(String.valueOf(entry.getValue()))) {
entry.setValue(getTextIndexerMapping());
} else if (isArray(String.valueOf(entry.getValue()))) {
entry.setValue(Records.Type.builder().type(getArrayMemberType(String.valueOf(entry.getValue()))).build());
} else {
entry.setValue(Records.Type.builder().type(entry.getValue().toString()).build());
}
......@@ -189,8 +192,8 @@ public class TypeMapper {
public static Object getObjectsArrayMapping(String dataType, Object properties) {
Map<String, Object> nestedMapping = new HashMap<>();
nestedMapping.put(Constants.TYPE,storageToIndexerType.getOrDefault(dataType, dataType));
nestedMapping.put(Constants.PROPERTIES,properties);
nestedMapping.put(Constants.TYPE, storageToIndexerType.getOrDefault(dataType, dataType));
nestedMapping.put(Constants.PROPERTIES, properties);
return nestedMapping;
}
......
......@@ -57,7 +57,7 @@ public class IndexerMappingServiceTest {
private final String kind = "tenant:test:test:1.0.0";
private final String index = "tenant-test-test-1.0.0";
private final String type = "test";
private final String validMapping = "{\"dynamic\":false,\"properties\":{\"data\":{\"properties\":{\"Msg\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"Location\":{\"type\":\"geo_point\"}}},\"authority\":{\"type\":\"constant_keyword\",\"value\":\"tenant\"},\"id\":{\"type\":\"keyword\"},\"acl\":{\"properties\":{\"viewers\":{\"type\":\"keyword\"},\"owners\":{\"type\":\"keyword\"}}}}}";
private final String validMapping = "{\"dynamic\":false,\"properties\":{\"data\":{\"properties\":{\"Msg\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"Intervals\":{\"properties\":{\"StopMarkerID\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"GeologicUnitInterpretationIDs\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"StopMeasuredDepth\":{\"type\":\"double\"}}},\"Location\":{\"type\":\"geo_point\"}}},\"authority\":{\"type\":\"constant_keyword\",\"value\":\"tenant\"},\"id\":{\"type\":\"keyword\"},\"acl\":{\"properties\":{\"viewers\":{\"type\":\"keyword\"},\"owners\":{\"type\":\"keyword\"}}}}}";
private final String emptyDataValidMapping = "{\"dynamic\":false,\"properties\":{\"id\":{\"type\":\"keyword\"},\"acl\":{\"properties\":{\"viewers\":{\"type\":\"keyword\"},\"owners\":{\"type\":\"keyword\"}}},\"authority\":{\"type\":\"constant_keyword\",\"value\":\"tenant\"}}}";
@Mock
......@@ -111,6 +111,13 @@ public class IndexerMappingServiceTest {
Map<String, Object> dataMapping = new HashMap<>();
dataMapping.put("Location", "geo_point");
dataMapping.put("Msg", "text");
Map<String, Object> intervalNestedAttribute = new HashMap<>();
Map<String, Object> intervalProperties = new HashMap<>();
intervalProperties.put("StopMarkerID", "text");
intervalProperties.put("GeologicUnitInterpretationIDs", "text");
intervalProperties.put("StopMeasuredDepth", "double");
intervalNestedAttribute.put("properties", intervalProperties);
dataMapping.put("Intervals", intervalNestedAttribute);
return dataMapping;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment