[Issue-16906] Fix Lineage Edge Being Removed in Non-Indexable Fields (#16907)

* Fix Lineage Edge Being Removed

* Else Condition
This commit is contained in:
Mohit Yadav 2024-07-03 14:21:10 +05:30 committed by GitHub
parent b65e084324
commit 02e06c7795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,9 +1,11 @@
package org.openmetadata.service.search; package org.openmetadata.service.search;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.openmetadata.schema.type.EntityReference; import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.TagLabel; import org.openmetadata.schema.type.TagLabel;
@ -32,20 +34,20 @@ public final class SearchIndexUtils {
String[] pathElements = path.split("\\."); String[] pathElements = path.split("\\.");
Map<String, Object> currentMap = jsonMap; Map<String, Object> currentMap = jsonMap;
for (int i = 0; i < pathElements.length - 1; i++) { String key = pathElements[0];
String key = pathElements[i]; Object value = currentMap.get(key);
Object value = currentMap.get(key); if (value instanceof Map) {
if (value instanceof Map) { currentMap = (Map<String, Object>) value;
currentMap = (Map<String, Object>) value; } else if (value instanceof List) {
} else if (value instanceof List) { List<Map<String, Object>> list = (List<Map<String, Object>>) value;
List<Map<String, Object>> list = (List<Map<String, Object>>) value; for (Map<String, Object> item : list) {
for (Map<String, Object> item : list) { removeFieldByPath(
removeFieldByPath(item, pathElements[i + 1]); item,
} Arrays.stream(pathElements, 1, pathElements.length).collect(Collectors.joining(".")));
} else {
// Path Not Found
return;
} }
return;
} else {
return;
} }
// Remove the field at the last path element // Remove the field at the last path element