Greeting to All!
I am a beginner with Neo4j and Cypher and have a problem with the following functionality:
I have a acyclic directed graph of Nodes that are connected with :DATA_FLOWS
edges
There could be more than one edge between two Nodes as these edges could have different Edge property - scenario_id
When I select one or more nodes (by group) and try to filter by one or more scenario_id (property of the edge) I would like to see all the dependent Nodes of a certain depth (*..n) that depend on my selection and edge filter
I am using the following query:
match p= (src:Node)-[:DATA_FLOWS*..5]->(dst:Node)
where src.group_id IN {Group} and all(x in RELATIONSHIPS(p) WHERE x.scenario_id IN {Scenario} )
RETURN p;
This looks OK in Neo4j browser that presents the results in a nice visual way, but I need to run this query in Tom Sawyer Perspective, which expects flat table-like result set, rather than Json...
So my query, after too many unsuccessful attempts, looks like:
match p= (src:Node)-[:DATA_FLOWS*..5]->(dst:Node)
where src.group_id IN {Group} and all(x in RELATIONSHIPS(p) WHERE x.scenario_id IN {Scenario} )
WITH p
MATCH (a)-[r:DATA_FLOWS]->(b)
where all(x in RELATIONSHIPS(p) WHERE ID(x) = ID(r))
RETURN a.id, r.scenario_id, b.id
I would greatly appreciate if anyone provides me any suggestions on how to improve, rewrite, etc this query and get a better performance.
Thank you in advance, Vlad
To formulate neo4j data in a tabular way, you should consider using the neo4j-jdbc driver which allows you to access a neo4j database as if it were any other relational database.
I'm not familiar with Tom Sawyer Perspective, but it's really common for visualization tools to support pulling data from a JDBC connection, so this might make your life a lot easier, and mean that you don't even have to export data to a tabular file format (CSV) before you bring it into your tool.