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