mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-06 23:52:29 +00:00
Minor: Add glossary index to SearchIndexFactory (#14690)
* Minor: Add glossary index to SearchIndexFactory * Minor: Add glossary index to SearchIndexFactory
This commit is contained in:
parent
99b8e7988d
commit
e786380915
@ -10,6 +10,7 @@ import org.openmetadata.schema.entity.data.Dashboard;
|
||||
import org.openmetadata.schema.entity.data.DashboardDataModel;
|
||||
import org.openmetadata.schema.entity.data.Database;
|
||||
import org.openmetadata.schema.entity.data.DatabaseSchema;
|
||||
import org.openmetadata.schema.entity.data.Glossary;
|
||||
import org.openmetadata.schema.entity.data.GlossaryTerm;
|
||||
import org.openmetadata.schema.entity.data.MlModel;
|
||||
import org.openmetadata.schema.entity.data.Pipeline;
|
||||
@ -46,6 +47,7 @@ import org.openmetadata.service.search.indexes.DatabaseSchemaIndex;
|
||||
import org.openmetadata.service.search.indexes.DatabaseServiceIndex;
|
||||
import org.openmetadata.service.search.indexes.DomainIndex;
|
||||
import org.openmetadata.service.search.indexes.EntityReportDataIndex;
|
||||
import org.openmetadata.service.search.indexes.GlossaryIndex;
|
||||
import org.openmetadata.service.search.indexes.GlossaryTermIndex;
|
||||
import org.openmetadata.service.search.indexes.MessagingServiceIndex;
|
||||
import org.openmetadata.service.search.indexes.MetadataServiceIndex;
|
||||
@ -82,6 +84,7 @@ public class SearchIndexFactory {
|
||||
case Entity.PIPELINE -> new PipelineIndex((Pipeline) entity);
|
||||
case Entity.USER -> new UserIndex((User) entity);
|
||||
case Entity.TEAM -> new TeamIndex((Team) entity);
|
||||
case Entity.GLOSSARY -> new GlossaryIndex((Glossary) entity);
|
||||
case Entity.GLOSSARY_TERM -> new GlossaryTermIndex((GlossaryTerm) entity);
|
||||
case Entity.MLMODEL -> new MlModelIndex((MlModel) entity);
|
||||
case Entity.TAG -> new TagIndex((Tag) entity);
|
||||
@ -119,11 +122,11 @@ public class SearchIndexFactory {
|
||||
(ReportData) entity);
|
||||
case Entity.TEST_CASE_RESOLUTION_STATUS -> new TestCaseResolutionStatusIndex(
|
||||
(TestCaseResolutionStatus) entity);
|
||||
default -> buildExternalIndexes(entityType, entity);
|
||||
default -> buildExternalIndexes(entityType);
|
||||
};
|
||||
}
|
||||
|
||||
protected SearchIndex buildExternalIndexes(String entityType, Object entity) {
|
||||
protected SearchIndex buildExternalIndexes(String entityType) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Entity Type [%s] is not valid for Index Factory", entityType));
|
||||
}
|
||||
|
@ -3,38 +3,37 @@ package org.openmetadata.service.search.indexes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.openmetadata.schema.entity.data.GlossaryTerm;
|
||||
import org.openmetadata.schema.entity.data.Glossary;
|
||||
import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.search.SearchIndexUtils;
|
||||
import org.openmetadata.service.search.models.SearchSuggest;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class GlossaryIndex implements SearchIndex {
|
||||
final GlossaryTerm glossaryTerm;
|
||||
final Glossary glossary;
|
||||
final List<String> excludeFields = List.of("changeDescription");
|
||||
|
||||
public GlossaryIndex(GlossaryTerm glossaryTerm) {
|
||||
this.glossaryTerm = glossaryTerm;
|
||||
public GlossaryIndex(Glossary glossary) {
|
||||
this.glossary = glossary;
|
||||
}
|
||||
|
||||
public Map<String, Object> buildESDoc() {
|
||||
Map<String, Object> doc = JsonUtils.getMap(glossaryTerm);
|
||||
Map<String, Object> doc = JsonUtils.getMap(glossary);
|
||||
SearchIndexUtils.removeNonIndexableFields(doc, excludeFields);
|
||||
List<SearchSuggest> 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());
|
||||
suggest.add(SearchSuggest.builder().input(glossary.getName()).weight(5).build());
|
||||
if (glossary.getDisplayName() != null && !glossary.getDisplayName().isEmpty()) {
|
||||
suggest.add(SearchSuggest.builder().input(glossary.getDisplayName()).weight(10).build());
|
||||
}
|
||||
doc.put(
|
||||
"fqnParts",
|
||||
getFQNParts(
|
||||
glossaryTerm.getFullyQualifiedName(),
|
||||
suggest.stream().map(SearchSuggest::getInput).collect(Collectors.toList())));
|
||||
glossary.getFullyQualifiedName(),
|
||||
suggest.stream().map(SearchSuggest::getInput).toList()));
|
||||
doc.put("suggest", suggest);
|
||||
doc.put("entityType", Entity.GLOSSARY);
|
||||
doc.put("owner", getEntityWithDisplayName(glossaryTerm.getOwner()));
|
||||
doc.put("domain", getEntityWithDisplayName(glossaryTerm.getDomain()));
|
||||
doc.put("owner", getEntityWithDisplayName(glossary.getOwner()));
|
||||
doc.put("domain", getEntityWithDisplayName(glossary.getDomain()));
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user