Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-24-2022 03:28 AM
How can I query multiple relationships and pass filter for just one of them?
eg:
match (u:User)-[:PURCHASED|r:RATED {r.value > 3.5}]->(i:Item) return i
Solved! Go to Solution.
11-24-2022 05:31 AM
Got it..try this:
match (u:User)-[r]->(i:Item)
where r:PURCHASED or (r:RATED and r.value > 3.5)
return u, i
11-24-2022 03:41 AM
Do you mean you would like to get all the items a user purchased where the user also rated with a rating greater than 3.5? If so, try this.
match (u:User)-[:PURCHASED]->(i:Item)
where exists {
match (u)-[r:RATED]->(i)
where r.value > 3.5
}
return u.name, collect(i.name)
11-24-2022 04:05 AM
No. I mean I wanna get all the items a user either purchased OR rated > some value.
11-24-2022 04:10 AM - edited 11-24-2022 04:14 AM
match (u:User)-[r:PURCHASED|RATED]->(i:Item) where r.value>3.4 return u, i
This kinda works but the other of the edges doesn't hold values. Only RATED edge has a value.
Nope, it only returns RATED nodes by the user.
11-24-2022 05:31 AM
Got it..try this:
match (u:User)-[r]->(i:Item)
where r:PURCHASED or (r:RATED and r.value > 3.5)
return u, i
11-24-2022 05:59 AM
Worked. Thank you!
All the sessions of the conference are now available online