As per my schema, I have a "Project" node and multiple "Revision" nodes connected to project. Every other node is connected to "Revision" nodes applicable. I need to fetch all nodes that are connected to a particular "Revision" node. While fetching nodes, I need to get the relationship between these nodes too. I need to restrict the nodes connected to a particular revision.
I tried below query, however, it degrades the performance as DB hits are more while profiling. Every revision will have around 28k nodes and 76k relationships between them.
MATCH (a:Project{name:{0}})-[h:HAS_REVISION]->(r:Revision)
WITH a
MATCH p=(a)-[h]->(r)-[*0..2]->(allRelatedNodes)
WHERE r.revisionNo={1} AND (r)-[]->(allRelatedNodes)
RETURN a, relationships(p), nodes(p)
below query is cost effective. I get expected results while querying the in-browser database. However, while executing from my Java application, relations between nodes connected to the particular "Revision" are not fetched.
PROFILE
MATCH (project:Project {name> :"test_local"})-[:HAS_REVISION]-
(revision:Revision{revisionNo:1})
WITH project,revision
MATCH p = (revision)-[]-(allRelatedNodes)
WITH project,revision,collect(p) as rs
RETURN project,revision,rs
Can anyone please help.
withclause. The second one looks OK, like it should work. Please post a java snippet and a more specific description of what you should be getting. You say you wantrelations between nodes connected to the particular "Revision"-- but you're collecting paths in the output of your query. So you may have a problem with how you're processing those paths for those relations. - FrobberOfBits