@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile) RETURN post")
I'd like to include the user's posts as well, but I got empty results on the following
@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post) RETURN post")
Do I need to do multiple matches or I missing something fundamental about expressing multiple rels?
Just getting started with cypher queries, so bear with me...I've created a query that finds a user's followers and returns the followers' posts in a List, like so:@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile) RETURN post")
I'd like to include the user's posts as well, but I got empty results on the following
@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post) RETURN post")
@Query("START post=node:Post(0) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post) WHERE post.profile.username={0} RETURN post")
Cheers,
/peter neubauer
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer
Neo4j - Graphs rule.
Program or be programmed - Computer Literacy for kids.
http://foocafe.org/#CoderDojo
@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post) RETURN post")
this however, returns all the posts of username={0}'s followers
@Query("START profile=node:Profile(username={0}) MATCH (post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile) RETURN post")
I've moved to 1.7MO2 and tried something like:
@Query("START post=node(*) MATCH (profile)<-[:POSTSOUTPROFILE]-(post) RETURN post WHERE profile.username IN ['name','another'] ")
Not sure if this is still open Greg?Cheers,
/peter neubauer
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauerNeo4j - Graphs rule.
Program or be programmed - Computer Literacy for kids.
http://foocafe.org/#CoderDojo
@Query("START profile=node:Profile(username={0}) MATCH
(post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post)
RETURN post")
means that the first and the last (post) ARE THE SAME post. I believe
that what you want is something like
@Query("START profile=node:Profile(username={0}) MATCH
(following_post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(profile_pos)
RETURN following_post, profile_post")
in order to return the correct data, possibly chunking it a bit with
Count(*) or group ...
Cheers,
/peter neubauer
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer
Neo4j - Graphs rule.
Program or be programmed - Computer Literacy for kids.
http://foocafe.org/#CoderDojo
@Query("START profile=node(1) MATCH (profile)<-[:POSTSOUTPROFILE]-(post)-[:POSTSOUTCHANNEL]->(channel)<-[:POSTSOUTCHANNEL]-(following_post)-[:POSTSOUTPROFILE]->(following) WHERE channel.channelName='Links' AND (following<-[:FOLLOWING]-profile AND following_post.hasPrivacy=false) RETURN post,following_post, Count(*) as postCount ORDER BY post.modified")
which then returned as using @MapResult.
However, I am getting duplicates in the results and have searched and tried various hacks for a few days on returning unique results,e.g. RETURN DISTINCT post.
Could you provide a litte more guidance on using count(*) or group as you suggsted?
Greg,
remember that when you bind a variable it means that it refers to the
SAME node in the pattern.@Query("START profile=node:Profile(username={0}) MATCH
(post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(post)
RETURN post")means that the first and the last (post) ARE THE SAME post. I believe
that what you want is something like@Query("START profile=node:Profile(username={0}) MATCH
(following_post)-[:POSTSOUTPROFILE]->(following)<-[:FOLLOWING]-(profile)<-[:POSTSOUTPROFILE]-(profile_pos)
RETURN following_post, profile_post")in order to return the correct data, possibly chunking it a bit with
Count(*) or group ...Cheers,
/peter neubauer
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauerNeo4j - Graphs rule.
Program or be programmed - Computer Literacy for kids.
http://foocafe.org/#CoderDojo
So I was able to get results as you suggested by doing this:@Query("START profile=node(1) MATCH (profile)<-[:POSTSOUTPROFILE]-(post)-[:POSTSOUTCHANNEL]->(channel)<-[:POSTSOUTCHANNEL]-(following_post)-[:POSTSOUTPROFILE]->(following) WHERE channel.channelName='Links' AND (following<-[:FOLLOWING]-profile AND following_post.hasPrivacy=false) RETURN post,following_post, Count(*) as postCount ORDER BY post.modified")
which then returned as using @MapResult.
However, I am getting duplicates in the results and have searched and tried various hacks for a few days on returning unique results,e.g. RETURN DISTINCT post.
Could you provide a litte more guidance on using count(*) or group as you suggsted?