diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java index 2378e7127afd..8364d017d589 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java @@ -775,7 +775,6 @@ public Map searchLineageInternal( boolean deleted, String entityType) throws IOException { - Set visitedFQN = new HashSet<>(); Map responseMap = new HashMap<>(); Set> edges = new HashSet<>(); Set> nodes = new HashSet<>(); @@ -800,7 +799,6 @@ public Map searchLineageInternal( } getLineage( fqn, - visitedFQN, downstreamDepth, edges, nodes, @@ -808,14 +806,7 @@ public Map searchLineageInternal( "lineage.fromEntity.fqnHash.keyword", deleted); getLineage( - fqn, - visitedFQN, - upstreamDepth, - edges, - nodes, - queryFilter, - "lineage.toEntity.fqnHash.keyword", - deleted); + fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqnHash.keyword", deleted); responseMap.put("edges", edges); responseMap.put("nodes", nodes); return responseMap; @@ -1041,7 +1032,6 @@ public Response searchSchemaEntityRelationship( private void getLineage( String fqn, - Set visitedFQN, int depth, Set> edges, Set> nodes, @@ -1049,10 +1039,9 @@ private void getLineage( String direction, boolean deleted) throws IOException { - if (depth <= 0 || visitedFQN.contains(fqn)) { + if (depth <= 0) { return; } - visitedFQN.add(fqn); es.org.elasticsearch.action.search.SearchRequest searchRequest = new es.org.elasticsearch.action.search.SearchRequest( Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS)); @@ -1082,27 +1071,13 @@ private void getLineage( if (!edges.contains(lin) && fromEntity.get("fqn").equals(fqn)) { edges.add(lin); getLineage( - toEntity.get("fqn"), - visitedFQN, - depth - 1, - edges, - nodes, - queryFilter, - direction, - deleted); + toEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); } } else { if (!edges.contains(lin) && toEntity.get("fqn").equals(fqn)) { edges.add(lin); getLineage( - fromEntity.get("fqn"), - visitedFQN, - depth - 1, - edges, - nodes, - queryFilter, - direction, - deleted); + fromEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); } } } @@ -1254,7 +1229,6 @@ private Map searchPipelineLineage( boolean deleted, Map responseMap) throws IOException { - Set visitedFQN = new HashSet<>(); Set> edges = new HashSet<>(); Set> nodes = new HashSet<>(); Object[] searchAfter = null; @@ -1300,7 +1274,6 @@ private Map searchPipelineLineage( edges.add(lin); getLineage( fromEntity.get("fqn"), - visitedFQN, upstreamDepth, edges, nodes, @@ -1309,7 +1282,6 @@ private Map searchPipelineLineage( deleted); getLineage( toEntity.get("fqn"), - visitedFQN, downstreamDepth, edges, nodes, @@ -1329,23 +1301,9 @@ private Map searchPipelineLineage( } } getLineage( - fqn, - visitedFQN, - downstreamDepth, - edges, - nodes, - queryFilter, - "lineage.fromEntity.fqn.keyword", - deleted); + fqn, downstreamDepth, edges, nodes, queryFilter, "lineage.fromEntity.fqn.keyword", deleted); getLineage( - fqn, - visitedFQN, - upstreamDepth, - edges, - nodes, - queryFilter, - "lineage.toEntity.fqn.keyword", - deleted); + fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqn.keyword", deleted); // TODO: Fix this , this is hack if (edges.isEmpty()) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java index 82f26cf2b218..b1f76a2c1a95 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java @@ -777,7 +777,6 @@ public Map searchLineageInternal( boolean deleted, String entityType) throws IOException { - Set visitedFQN = new HashSet<>(); if (entityType.equalsIgnoreCase(Entity.PIPELINE) || entityType.equalsIgnoreCase(Entity.STORED_PROCEDURE)) { return searchPipelineLineage(fqn, upstreamDepth, downstreamDepth, queryFilter, deleted); @@ -802,7 +801,6 @@ public Map searchLineageInternal( } getLineage( fqn, - visitedFQN, downstreamDepth, edges, nodes, @@ -810,14 +808,7 @@ public Map searchLineageInternal( "lineage.fromEntity.fqnHash.keyword", deleted); getLineage( - fqn, - visitedFQN, - upstreamDepth, - edges, - nodes, - queryFilter, - "lineage.toEntity.fqnHash.keyword", - deleted); + fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqnHash.keyword", deleted); responseMap.put("edges", edges); responseMap.put("nodes", nodes); return responseMap; @@ -1041,7 +1032,6 @@ public Response searchSchemaEntityRelationship( private void getLineage( String fqn, - Set visitedFQN, int depth, Set> edges, Set> nodes, @@ -1049,10 +1039,9 @@ private void getLineage( String direction, boolean deleted) throws IOException { - if (depth <= 0 || visitedFQN.contains(fqn)) { + if (depth <= 0) { return; } - visitedFQN.add(fqn); os.org.opensearch.action.search.SearchRequest searchRequest = new os.org.opensearch.action.search.SearchRequest( Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS)); @@ -1084,27 +1073,13 @@ private void getLineage( if (!edges.contains(lin) && fromEntity.get("fqn").equals(fqn)) { edges.add(lin); getLineage( - toEntity.get("fqn"), - visitedFQN, - depth - 1, - edges, - nodes, - queryFilter, - direction, - deleted); + toEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); } } else { if (!edges.contains(lin) && toEntity.get("fqn").equals(fqn)) { edges.add(lin); getLineage( - fromEntity.get("fqn"), - visitedFQN, - depth - 1, - edges, - nodes, - queryFilter, - direction, - deleted); + fromEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); } } } @@ -1251,7 +1226,6 @@ private SearchResponse performLineageSearch(String fqn, String queryFilter, bool private Map searchPipelineLineage( String fqn, int upstreamDepth, int downstreamDepth, String queryFilter, boolean deleted) throws IOException { - Set visitedFQN = new HashSet<>(); Map responseMap = new HashMap<>(); Set> edges = new HashSet<>(); Set> nodes = new HashSet<>(); @@ -1298,7 +1272,6 @@ private Map searchPipelineLineage( edges.add(lin); getLineage( fromEntity.get("fqn"), - visitedFQN, upstreamDepth, edges, nodes, @@ -1307,7 +1280,6 @@ private Map searchPipelineLineage( deleted); getLineage( toEntity.get("fqn"), - visitedFQN, downstreamDepth, edges, nodes, @@ -1327,23 +1299,9 @@ private Map searchPipelineLineage( } } getLineage( - fqn, - visitedFQN, - downstreamDepth, - edges, - nodes, - queryFilter, - "lineage.fromEntity.fqn.keyword", - deleted); + fqn, downstreamDepth, edges, nodes, queryFilter, "lineage.fromEntity.fqn.keyword", deleted); getLineage( - fqn, - visitedFQN, - upstreamDepth, - edges, - nodes, - queryFilter, - "lineage.toEntity.fqn.keyword", - deleted); + fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqn.keyword", deleted); if (edges.isEmpty()) { os.org.opensearch.action.search.SearchRequest searchRequestForEntity =