I am working on an app which uses NEO4J. There are mainly two types of Nodes
- User - User nodes can be connected among each other with relationship 'FRIENDS'
- Post - Posts nodes consists of posts created by the users and has a relationship of 'OWNED_BY' between user who created the post and the actual post node
- Consider there are 3 users A,B,C and 4 posts B1,B2 (from user B) and C1,C2 (from user C)
- A and B are connected with 'FRIENDS'
- For user A the post display order should be B1,B2,C1,C2 on his/her dashboard ( i.e. we should display the posts which are created by the immediate network followed by posts which are not from his/her network)
Need some guidance on how this can be achieved using CYPHER query
What I'm trying to do
MATCH(n:User)-[r:FRIENDS_WITH]-(u1:User) where n.name = 'A' with u1 match(s:Post)-[r1:OWNED_BY]-(u1) UNION (Trying to figure out how to select Post which are not in s ) I'm trying to address based on my SQL knowledge. I'm getting posts of all users who are FRIENDS_WITH 'A' and after this I want to do a UNION of missing posts, but unable to figure this out
Please do let me know if there's a better way of achieving the outcome. Thank you so much