silly-accountant-1288
02/01/2023, 7:14 AMfinal String multiHopTemplateDirect = "MATCH (a {urn: '%s'})-[r:%s*1..%d]->(b) WHERE b:%s RETURN a,r,b";
final String multiHopTemplateIndirect = "MATCH (a {urn: '%s'})<-[r:%s*1..%d]-(b) WHERE b:%s RETURN a,r,b";
should it become?:
final String multiHopTemplateDirect = "MATCH shortestPath((a {urn: '%s'})-[r:%s*1..%d]->(b)) WHERE b.urn <> '%s' AND b:%s RETURN a,r,b";
final String multiHopTemplateIndirect = "MATCH shortestPath((a {urn: '%s'})<-[r:%s*1..%d]-(b)) WHERE b.urn <> '%s' AND b:%s RETURN a,r,b";
and also remove:
// It is possible to have more than 1 path from node A to node B in the graph and previous query returns all the paths.
// We convert the List into Map with only the shortest paths. "item.get(i).size()" is the path size between two nodes in relation.
// The key for mapping is the destination node as the source node is always the same, and it is defined by parameter.
neo4jResult = neo4jResult.stream()
.collect(Collectors.toMap(item -> item.values().get(2).asNode().get("urn").asString(), Function.identity(),
(item1, item2) -> item1.get(1).size() < item2.get(1).size() ? item1 : item2))
.values()
.stream()
.collect(Collectors.toList());bulky-soccer-26729
02/01/2023, 3:18 PMsilly-accountant-1288
02/02/2023, 3:38 AMbulky-soccer-26729
02/02/2023, 4:30 PMsilly-accountant-1288
02/03/2023, 12:46 AMsilly-accountant-1288
02/03/2023, 7:04 AM"WITH %d as startTimeMillis, %d as endTimeMillis "
"MATCH shortestPath((a {urn: '%s'})-[r:%s*1..%d]->(b:%s)) "
"WHERE b.urn <> '%s' "
"WIth *, "
"(r[-1]).createdOn >= startTimeMillis as s_true, "
"(r[0]).createdOn <= endTimeMillis as e_true , "
"ALL(i in range(0, size(r)-2) WHERE (r[i]).createdOn >= startTime AND (r[i]).createdOn <= endTime) as c "
"WHERE s_true and e_true and c "
"RETURN a, r, b Limit %d";bulky-soccer-26729
02/03/2023, 5:09 PMfierce-guitar-16421
03/29/2023, 9:35 PMr_ edges are nice for lineages, but we also realise that duplicate edges are now added to all entity relationships, which do not appear very useful and make it more difficult to view the graphs (see pic below), and also lead to higher consumption of Neo4j storage.
Would it be a good idea to limit the r_ edges to lineage relationships only? Even if so Iâm still wondering, for lineage, if there is a strong rationale to introduce reversed edges, while the original edge directions seem sufficient to me (as Neo4j works bidirectionally for planning shortest paths). Could we simply enrich the original edges with the timestamp/actor/etc. properties?
Thanks!
FYI @bulky-soccer-26729 @echoing-airport-49548 @silly-accountant-1288silly-accountant-1288
03/30/2023, 2:58 AMtable_A <-Consumes- job1 -Produces-> table_B
table_A <-DownstreamOf- tableD
table_A -DownstreamOf-> table_E
using bidirectional cypher is really hard to find upstream lineage or downstream lineage.
please share if you have better solutions!!đ„°fierce-guitar-16421
03/31/2023, 4:00 PMMATCH shortestPath((a {urn: "%s"})-[r:DownstreamOf|Consumes|IsProducedBy*1..%d]-(b)) WHERE b.urn <> "%s" RETURN a,r,b
and the shortest path query can walk through both Datasets and DataJobs. No further types of edges seem to be needed.
But still, at least it might be worth considering to avoid adding the r_ edges to the non-lineage relationships, since they donât appear to be very useful for now.