org.openmetadata.service.search.indexes.GlossaryTermIndex Maven / Gradle / Ivy
package org.openmetadata.service.search.indexes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.openmetadata.schema.entity.data.GlossaryTerm;
import org.openmetadata.service.Entity;
import org.openmetadata.service.search.models.SearchSuggest;
public class GlossaryTermIndex implements SearchIndex {
final GlossaryTerm glossaryTerm;
public GlossaryTermIndex(GlossaryTerm glossaryTerm) {
this.glossaryTerm = glossaryTerm;
}
@Override
public List getSuggest() {
List suggest = new ArrayList<>();
suggest.add(SearchSuggest.builder().input(glossaryTerm.getName()).weight(5).build());
if (glossaryTerm.getDisplayName() != null && !glossaryTerm.getDisplayName().isEmpty()) {
suggest.add(SearchSuggest.builder().input(glossaryTerm.getDisplayName()).weight(10).build());
}
return suggest;
}
@Override
public Object getEntity() {
return glossaryTerm;
}
public Map buildSearchIndexDocInternal(Map doc) {
Map commonAttributes =
getCommonAttributesMap(glossaryTerm, Entity.GLOSSARY_TERM);
doc.putAll(commonAttributes);
return doc;
}
public static Map getFields() {
Map fields = SearchIndex.getDefaultFields();
fields.put("synonyms", 5.0f);
fields.put("synonyms.ngram", 1.0f);
fields.put("glossary.name", 5.0f);
fields.put("glossary.displayName", 5.0f);
return fields;
}
}