mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-30 08:57:09 +00:00
fix: Convert dynamic Elasticsearch scripts to parameterized scripts to avoid compilation limit (#23393)
(cherry picked from commit 72e2aeb0b8410aca90c0a065b85fd66c1a2d5417)
This commit is contained in:
parent
7c76023b96
commit
46fb77fd8e
@ -49,6 +49,7 @@ import jakarta.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -1131,7 +1132,8 @@ public class LineageRepository {
|
||||
searchClient.updateChildren(
|
||||
GLOBAL_SEARCH_ALIAS,
|
||||
new ImmutablePair<>("upstreamLineage.docUniqueId.keyword", uniqueValue),
|
||||
new ImmutablePair<>(String.format(REMOVE_LINEAGE_SCRIPT, uniqueValue), null));
|
||||
new ImmutablePair<>(
|
||||
REMOVE_LINEAGE_SCRIPT, Collections.singletonMap("docUniqueId", uniqueValue)));
|
||||
}
|
||||
|
||||
private EntityLineage getLineage(
|
||||
|
||||
@ -101,10 +101,10 @@ public interface SearchClient<T> {
|
||||
+ "}";
|
||||
|
||||
String REMOVE_LINEAGE_SCRIPT =
|
||||
"ctx._source.upstreamLineage.removeIf(lineage -> lineage.docUniqueId == '%s')";
|
||||
"ctx._source.upstreamLineage.removeIf(lineage -> lineage.docUniqueId == params.docUniqueId)";
|
||||
|
||||
String REMOVE_ENTITY_RELATIONSHIP =
|
||||
"ctx._source.upstreamEntityRelationship.removeIf(relationship -> relationship.docId == '%s')";
|
||||
"ctx._source.upstreamEntityRelationship.removeIf(relationship -> relationship.docId == params.docId)";
|
||||
|
||||
String ADD_UPDATE_LINEAGE =
|
||||
"boolean docIdExists = false; for (int i = 0; i < ctx._source.upstreamLineage.size(); i++) { if (ctx._source.upstreamLineage[i].docUniqueId.equalsIgnoreCase(params.lineageData.docUniqueId)) { ctx._source.upstreamLineage[i] = params.lineageData; docIdExists = true; break;}}if (!docIdExists) {ctx._source.upstreamLineage.add(params.lineageData);}";
|
||||
@ -155,7 +155,7 @@ public interface SearchClient<T> {
|
||||
ctx._source.tags = uniqueTags;
|
||||
""";
|
||||
String REMOVE_TEST_SUITE_CHILDREN_SCRIPT =
|
||||
"ctx._source.testSuites.removeIf(suite -> suite.id == '%s')";
|
||||
"ctx._source.testSuites.removeIf(suite -> suite.id == params.suiteId)";
|
||||
|
||||
String ADD_OWNERS_SCRIPT =
|
||||
"if (ctx._source.owners == null || ctx._source.owners.isEmpty() || "
|
||||
|
||||
@ -1060,7 +1060,9 @@ public class SearchRepository {
|
||||
searchClient.updateChildren(
|
||||
indexMapping.getChildAliases(clusterAlias),
|
||||
new ImmutablePair<>("testSuites.id", testSuite.getId().toString()),
|
||||
new ImmutablePair<>(REMOVE_TEST_SUITE_CHILDREN_SCRIPT, null));
|
||||
new ImmutablePair<>(
|
||||
REMOVE_TEST_SUITE_CHILDREN_SCRIPT,
|
||||
Collections.singletonMap("suiteId", testSuite.getId().toString())));
|
||||
}
|
||||
}
|
||||
case Entity.DASHBOARD_SERVICE,
|
||||
@ -1413,7 +1415,8 @@ public class SearchRepository {
|
||||
searchClient.updateChildren(
|
||||
GLOBAL_SEARCH_ALIAS,
|
||||
new ImmutablePair<>("upstreamEntityRelationship.docId.keyword", relationDocId),
|
||||
new ImmutablePair<>(String.format(REMOVE_ENTITY_RELATIONSHIP, relationDocId), null));
|
||||
new ImmutablePair<>(
|
||||
REMOVE_ENTITY_RELATIONSHIP, Collections.singletonMap("docId", relationDocId)));
|
||||
}
|
||||
|
||||
public QueryCostSearchResult getQueryCostRecords(String serviceName) throws IOException {
|
||||
|
||||
@ -8,6 +8,7 @@ import static org.openmetadata.service.jdbi3.LineageRepository.getDocumentUnique
|
||||
import static org.openmetadata.service.search.SearchClient.GLOBAL_SEARCH_ALIAS;
|
||||
import static org.openmetadata.service.search.SearchClient.REMOVE_LINEAGE_SCRIPT;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
@ -122,7 +123,8 @@ public class LineageUtil {
|
||||
.updateChildren(
|
||||
GLOBAL_SEARCH_ALIAS,
|
||||
new ImmutablePair<>("upstreamLineage.docUniqueId.keyword", uniqueValue),
|
||||
new ImmutablePair<>(String.format(REMOVE_LINEAGE_SCRIPT, uniqueValue), null));
|
||||
new ImmutablePair<>(
|
||||
REMOVE_LINEAGE_SCRIPT, Collections.singletonMap("docUniqueId", uniqueValue)));
|
||||
}
|
||||
|
||||
private static void insertDomainLineage(EntityReference fromDomain, EntityReference toDomain) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user