I'm using neo4j 2.1.2 version community edition. I have one issue in finding the path which i'm looking for using cypher. I have data in csv file and loaded the data into neo4j database using LOAD CSV option. The data looks like below:
Query Used:
LOAD CSV WITH HEADERS FROM "file:C:\\WorkingFolder\\Neo4j\\EDGE_Graph_POC\\newdata\\test.csv " as file
MERGE (role:Role {Role:file.RoleName})
MERGE (u:User {User:file.UserName})
Merge (c:Country {Country:file.Country})
MERGE (s:State {State: file.State})
MERGE (a:Address {Address:file.Address})
MERGE (comp:Company {Company: file.Company})
MERGE (u)-[:Has]->(role)-[:GivenAccess_To]->(a)-[:Present_IN]->(s)-[:Belongs_TO]->(c)- [:Comes_Under]->(comp)
Data file Used:
Resultant Graph:
Then I merged two addresses into a single Address with a relationship as below and given access to a User called 'Susan Smith' to access the newly merged address which is shown below: Graph:
Issue I'm facing: Here If someone wants to see the merged address which belongs to which country and state and also to see which user is given access.Also in the above image i have marked the path which i'm looking for.
The query i used to get the path is :
match path = (x)-[r1:Merged_TO]->(y)
with y
match path1 = (u:User)-[:Has]->()-[:GivenAccess_To]->(y)-[:Present_IN]->(s)-[:Belongs_TO]->(b)-[:Comes_Under]->(comp)
return path1;
Output Graph :
But here i'm supposed to get only one user called Susen Smith
but getting all the users who are attached to Publisher
node. So how can i get that information.
Expected Graph is :
**NOTE :**
Here i do not want to pass the User name. wheneven i enter the Merged_TO relationship, i should get the new merged node and user information who is supposed to access that node.
How can i do it?