Hi, For the graph you displayed, this should work:
MATCH (w)-[:WRITES]->(a) RETURN w, a; This should return all nodes connected to 'w' node with the relation 'WRITES'. -Kamal On Saturday, 18 August 2018 04:43:02 UTC-7, Shashika Ranga Muramudalige wrote: > > Hi, > > > I need to query the following graph (query graph) or its sub-graphs from > my dataset in neo4j. > > > [image: stackoverflow.png] > > > > > > > > > > > > > > > > * Figure : Query graph* > > > I have tried with the following query. > > OPTIONAL MATCH (w:W)-[:WRITES]->(a1:A{name:"A1"}) > WITH w,a1 > OPTIONAL MATCH (w)-[:WRITES]->(a2:A{name:"A2"}) > WITH w,a1,a2 > OPTIONAL MATCH (w)-[:WRITES]->(a3:A{name:"A3"}) > WITH w,a1,a2,a3 > OPTIONAL MATCH (w)-[:WRITES]->(a4:A{name:"A4"}) > RETURN w,a1,a2,a3,a4 > > > But it doesn't give me the accepted results because it is still a logical > AND operation. Further, results depend on the order of the match in the > query too. > > I think I need a kind of an approach. > > MATCH (w:W)-[:WRITES]->(a1:A{name:"A1"}) > > *OR/AND* > > MATCH (w)-[:WRITES]->(a2:A{name:"A2"}) > > *OR/AND* > > MATCH (w)-[:WRITES]->(a3:A{name:"A3"}) > > *OR/AND* > > MATCH (w)-[:WRITES]->(a4:A{name:"A4"}) > RETURN w,a1,a2,a3,a4 > > > > Do I have any luck to achieve this with Neo4j? Your comments are highly > appreciated. > > > Thanks a lot. > > Best Regards, > Shashika > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.