I have a simple social network graph db model. Users can follow other users and post posts. I am trying to get a list of all posts that a user has posted along with any that anyone the user follows has posted
START a=node:node_auto_index(UserIdentifier = "USER0") MATCH (a)-[:POSTED]->(b), (a)-[:FOLLOWS]->(c)-[:POSTED]->(d) RETURN b, d;
It is returning the cross product of the two, a tuple of all the values in b joined with all the values in d. (b x d) I would like just a straight list of posts. How do I do this? Do I need to do two separate queries?
Neo4j 1.8RC1, Windows, Java 7
--
--
START a=node:node_auto_index(UserIdentifier = "USER0")
MATCH (a)-[:POSTED]->(b)
WITH collect(b) as posts
MATCH (a)-[:FOLLOWS]->(c)-[:POSTED]->(d)
RETURN posts, collect(d) as followersPosts;
HTH,
Andrés
I have a simple social network graph db model. Users can follow other users and post posts. I am trying to get a list of all posts that a user has posted along with any that anyone the user follows has posted
START a=node:node_auto_index(UserIdentifier = "USER0") MATCH (a)-[:POSTED]->(b), (a)-[:FOLLOWS]->(c)-[:POSTED]->(d) RETURN b, d;
It is returning the cross product of the two, a tuple of all the values in b joined with all the values in d. (b x d) I would like just a straight list of posts. How do I do this? Do I need to do two separate queries?
Neo4j 1.8RC1, Windows, Java 7
--
START a=node:node_auto_index(UserIdentifier = "USER0")
MATCH (a)-[:POSTED]->(b)
WITH a, collect(b) as posts
MATCH (a)-[:FOLLOWS]->(c)-[:POSTED]->(d)
RETURN posts, collect(d) as followersPosts;