简体   繁体   中英

Cypher Query to get connected nodes from two relations

I'm newbie to Neo4j/GraphDB and have created following simple graph

node[1]user1 which is 'friend' with node[2]user2 and node[3]user3 and all 3 above user have 'post' nodes connected to them as well..

question is how to get user1's connected friend and their post as well?

following query returns friends of user1 and his post only...

START user1=node(2) MATCH user1-->all_node RETURN all_node

Depending on the relationship types you have chosen, something like this should work:

START user1=node(2) 
MATCH user1-[:FRIEND]->friend-[:POST]->post 
RETURN friend,post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM