org.openmetadata.service.search.SearchIndexUtils Maven / Gradle / Ivy
package org.openmetadata.service.search;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.TagLabel;
public final class SearchIndexUtils {
private SearchIndexUtils() {}
public static List parseFollowers(List followersRef) {
if (followersRef == null) {
return Collections.emptyList();
}
return followersRef.stream().map(item -> item.getId().toString()).toList();
}
public static void removeNonIndexableFields(Map doc, Set fields) {
for (String key : fields) {
if (key.contains(".")) {
removeFieldByPath(doc, key);
} else {
doc.remove(key);
}
}
}
public static void removeFieldByPath(Map jsonMap, String path) {
String[] pathElements = path.split("\\.");
Map currentMap = jsonMap;
String key = pathElements[0];
Object value = currentMap.get(key);
if (value instanceof Map) {
currentMap = (Map) value;
} else if (value instanceof List) {
List