org.openmetadata.service.search.indexes.TeamIndex Maven / Gradle / Ivy
package org.openmetadata.service.search.indexes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.entity.teams.Team;
import org.openmetadata.service.Entity;
import org.openmetadata.service.search.models.SearchSuggest;
public class TeamIndex implements SearchIndex {
final Team team;
final Set excludeFields = Set.of("owns");
public TeamIndex(Team team) {
this.team = team;
}
@Override
public List getSuggest() {
List suggest = new ArrayList<>();
suggest.add(SearchSuggest.builder().input(team.getName()).weight(5).build());
suggest.add(SearchSuggest.builder().input(team.getDisplayName()).weight(10).build());
return suggest;
}
@Override
public Object getEntity() {
return team;
}
@Override
public Set getExcludedFields() {
return excludeFields;
}
public Map buildSearchIndexDocInternal(Map doc) {
Map commonAttributes = getCommonAttributesMap(team, Entity.TEAM);
doc.putAll(commonAttributes);
doc.put("isBot", false);
doc.put(
"displayName",
CommonUtil.nullOrEmpty(team.getDisplayName()) ? team.getName() : team.getDisplayName());
return doc;
}
}