mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 11:56:01 +00:00
Fix Certification tags not updating in ES (#18952)
* Fix Certification tags not updating in ES * Move code to search repository
This commit is contained in:
parent
b3c76292b8
commit
ac5bbb1673
@ -13,6 +13,7 @@
|
||||
|
||||
package org.openmetadata.service.jdbi3;
|
||||
|
||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
||||
import static org.openmetadata.schema.type.Include.ALL;
|
||||
import static org.openmetadata.schema.type.Include.NON_DELETED;
|
||||
import static org.openmetadata.service.Entity.CLASSIFICATION;
|
||||
@ -31,7 +32,6 @@ import java.util.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.common.utils.CommonUtil;
|
||||
import org.openmetadata.schema.BulkAssetsRequestInterface;
|
||||
import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.api.AddTagToAssetsRequest;
|
||||
@ -135,7 +135,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
List<BulkResponse> failures = new ArrayList<>();
|
||||
List<BulkResponse> success = new ArrayList<>();
|
||||
|
||||
if (dryRun || CommonUtil.nullOrEmpty(request.getAssets())) {
|
||||
if (dryRun || nullOrEmpty(request.getAssets())) {
|
||||
// Nothing to Validate
|
||||
return result
|
||||
.withStatus(ApiStatus.SUCCESS)
|
||||
@ -176,7 +176,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
result.setNumberOfRowsFailed(result.getNumberOfRowsFailed() + 1);
|
||||
}
|
||||
// Validate and Store Tags
|
||||
if (CommonUtil.nullOrEmpty(result.getFailedRequest())) {
|
||||
if (nullOrEmpty(result.getFailedRequest())) {
|
||||
List<TagLabel> tempList = new ArrayList<>(asset.getTags());
|
||||
tempList.add(tagLabel);
|
||||
// Apply Tags to Entities
|
||||
|
@ -74,6 +74,9 @@ public interface SearchClient {
|
||||
String REMOVE_TAGS_CHILDREN_SCRIPT =
|
||||
"for (int i = 0; i < ctx._source.tags.length; i++) { if (ctx._source.tags[i].tagFQN == params.fqn) { ctx._source.tags.remove(i) }}";
|
||||
|
||||
String UPDATE_CERTIFICATION_SCRIPT =
|
||||
"if (ctx._source.certification != null && ctx._source.certification.tagLabel != null) {ctx._source.certification.tagLabel.style = params.style; ctx._source.certification.tagLabel.description = params.description; ctx._source.certification.tagLabel.tagFQN = params.tagFQN; ctx._source.certification.tagLabel.name = params.name; }";
|
||||
|
||||
String REMOVE_LINEAGE_SCRIPT =
|
||||
"for (int i = 0; i < ctx._source.lineage.length; i++) { if (ctx._source.lineage[i].doc_id == '%s') { ctx._source.lineage.remove(i) }}";
|
||||
|
||||
|
@ -24,6 +24,7 @@ import static org.openmetadata.service.search.SearchClient.REMOVE_TAGS_CHILDREN_
|
||||
import static org.openmetadata.service.search.SearchClient.REMOVE_TEST_SUITE_CHILDREN_SCRIPT;
|
||||
import static org.openmetadata.service.search.SearchClient.SOFT_DELETE_RESTORE_SCRIPT;
|
||||
import static org.openmetadata.service.search.SearchClient.UPDATE_ADDED_DELETE_GLOSSARY_TAGS;
|
||||
import static org.openmetadata.service.search.SearchClient.UPDATE_CERTIFICATION_SCRIPT;
|
||||
import static org.openmetadata.service.search.SearchClient.UPDATE_PROPAGATED_ENTITY_REFERENCE_FIELD_SCRIPT;
|
||||
import static org.openmetadata.service.search.models.IndexMapping.indexNameSeparator;
|
||||
import static org.openmetadata.service.util.EntityUtil.compareEntityReferenceById;
|
||||
@ -58,6 +59,7 @@ import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.EntityTimeSeriesInterface;
|
||||
import org.openmetadata.schema.analytics.ReportData;
|
||||
import org.openmetadata.schema.dataInsight.DataInsightChartResult;
|
||||
import org.openmetadata.schema.entity.classification.Tag;
|
||||
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
||||
import org.openmetadata.schema.tests.DataQualityReport;
|
||||
import org.openmetadata.schema.tests.TestSuite;
|
||||
@ -366,7 +368,7 @@ public class SearchRepository {
|
||||
entityType, entityId, entity.getChangeDescription(), indexMapping, entity);
|
||||
propagateGlossaryTags(
|
||||
entityType, entity.getFullyQualifiedName(), entity.getChangeDescription());
|
||||
|
||||
propagateCertificationTags(entityType, entity);
|
||||
propagatetoRelatedEntities(
|
||||
entityType, entityId, entity.getChangeDescription(), indexMapping, entity);
|
||||
} catch (Exception ie) {
|
||||
@ -452,6 +454,24 @@ public class SearchRepository {
|
||||
}
|
||||
}
|
||||
|
||||
public void propagateCertificationTags(String entityType, EntityInterface entity) {
|
||||
ChangeDescription changeDescription = entity.getChangeDescription();
|
||||
if (changeDescription != null && entityType.equalsIgnoreCase(Entity.TAG)) {
|
||||
Tag tagEntity = (Tag) entity;
|
||||
if (tagEntity.getClassification().getFullyQualifiedName().equals("Certification")) {
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("name", entity.getName());
|
||||
paramMap.put("description", entity.getDescription());
|
||||
paramMap.put("tagFQN", entity.getFullyQualifiedName());
|
||||
paramMap.put("style", entity.getStyle());
|
||||
searchClient.updateChildren(
|
||||
GLOBAL_SEARCH_ALIAS,
|
||||
new ImmutablePair<>("certification.tagLabel.tagFQN", entity.getFullyQualifiedName()),
|
||||
new ImmutablePair<>(UPDATE_CERTIFICATION_SCRIPT, paramMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void propagatetoRelatedEntities(
|
||||
String entityType,
|
||||
String entityId,
|
||||
|
@ -150,8 +150,8 @@
|
||||
"indexName": "tag_search_index",
|
||||
"indexMappingFile": "/elasticsearch/%s/tag_index_mapping.json",
|
||||
"alias": "tag",
|
||||
"parentAliases": ["classification","all", "dataAsset"],
|
||||
"childAliases": []
|
||||
"parentAliases": ["classification"],
|
||||
"childAliases": ["all", "dataAsset"]
|
||||
},
|
||||
"classification": {
|
||||
"indexName": "classification_search_index",
|
||||
|
Loading…
x
Reference in New Issue
Block a user