Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-02-2019 07:09 AM
MATCH (me)-[post_rel_source:FOLLOWS_TEAM|:FOLLOWS|:FOLLOWS_EVENT*0..1]->(user)
In above case how can I check different 'status' of all 3 relations?
FOLLOWS_TEAM has accepted:1
FOLLOWS has accepted:1
FOLLOWS_EVENT dont have any status.
If I add like following, its not working for 'FOLLOWS_EVENT'
[post_rel_source:FOLLOWS_TEAM|:FOLLOWS|:EVENTS_OF_ORG*0..1{accepted:1}]
Solved! Go to Solution.
01-03-2019 12:18 PM
In this case we may need to use predicates to filter to the right relationships, which means breaking this big match down:
MATCH (me:User)-[:FOLLOWS_ORG*0..1{requeststatus:1}]->(orgOrUser)
WHERE me.userid='32387'
MATCH (orgOrUser)-[post_rel_source:FOLLOWS_TEAM|:FOLLOWS|:EVENTS_OF_ORG*0..1]->(users)- [:POSTED]->(mypost:Wallpost)
WHERE size(post_rel_source) = 0 OR type(post_rel_source[0]) = 'EVENTS_OF_ORG' OR post_rel_source[0].requeststatus = 1
RETURN me, users, mypost;
01-02-2019 07:39 AM
The way you've stated your query, you're asking for a single relationship with multiple types, which won't work because such a relationship can't exist in Neo4j. The way to do what you want is to break out the match 3 ways, and then use WHERE conditions. Like this:
MATCH (me)-[r1:FOLLOWS_TEAM]->(user)
MATCH (me)-[r2:FOLLOWS]->(user)
MATCH (m3)-[r3:FOLLOWS_EVENT]->(user)
WHERE r1.accepted = 1 AND r2.accepted = 1
Notice that this treats the three different relationships as all separate. Take care to make sure you're matching the right user (those three different relationships could go to different users). Finally, I can't help with how to express "don't have any status" on FOLLOWS_EVENT because this depends on what you mean by status. Maybe you want WHERE r3.accepted IS NULL
.
01-03-2019 03:57 AM
This looks promising
But In this case 'user' node is not showing combination of all 3 MATCH outputs.
01-03-2019 06:19 AM
I'm not sure what you mean. It'd be helpful to post the entire query, what its output is, along with what you expect the output to be.
01-03-2019 06:49 AM
My problem statement is
me FOLLOWS_TEAM {isaccepted=1} team
me FOLLOWS {isaccepted=1} user
me FOLLOWS {isaccepted=1} event
me FOLLOWS_ORG {isaccepted=1} Org
Org EVENTS_OF_ORG event
I want list post of user+teams+org's all teams to whom 'me' is following.
I came up with following solution
MATCH (me:User)-[f:FOLLOWS_ORG*0..1{requeststatus:1}]->(org)-[post_rel_source:FOLLOWS_TEAM|:FOLLOWS|:EVENTS_OF_ORG*0..1]->(users)- [post_rel:POSTED]->(mypost:Wallpost)
WHERE me.userid='32387'
RETURN me,users,mypost;
but in this query, I want to check weither user / team / Event/org has accepted my follow request.
EVENTS_OF_ORG this relation dont have any status.
NOTE - If 'me' is following 'Org', we no need to check status.
01-03-2019 12:18 PM
In this case we may need to use predicates to filter to the right relationships, which means breaking this big match down:
MATCH (me:User)-[:FOLLOWS_ORG*0..1{requeststatus:1}]->(orgOrUser)
WHERE me.userid='32387'
MATCH (orgOrUser)-[post_rel_source:FOLLOWS_TEAM|:FOLLOWS|:EVENTS_OF_ORG*0..1]->(users)- [:POSTED]->(mypost:Wallpost)
WHERE size(post_rel_source) = 0 OR type(post_rel_source[0]) = 'EVENTS_OF_ORG' OR post_rel_source[0].requeststatus = 1
RETURN me, users, mypost;
All the sessions of the conference are now available online