Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-20-2020 04:23 AM
Hello! I need help with forming a Cypher query
For a graph with 2 types of nodes :User and :Event and 2 types of relationships :OWNS and :PARTICIPATES_IN,
I want to get a list of all events that a user participates in along with the owner of that event and no more that 4 other participants of the same event.
Your help is much appreciated.
Thanks
Sachin
07-20-2020 12:18 PM
Hello! Welcome to the community.
You could try something like this with Neo4j 4.1 by using a subquery:
MATCH (u:User)-[:PARTICIPATES_IN]->(e:Event)
CALL {
WITH u, e
MATCH (u)-[:OWNS]->(e)<-[:PARTICIPATES_IN]-(o:User)
RETURN o, u LIMIT 4
}
RETURN u, e, o
Not sure if that's exactly how your graph is structured but something along those lines should get it done. Here's an example of something similar in the new docs https://neo4j.com/developer/kb/limiting-match-results-per-row/
07-21-2020 02:29 AM
Thank you very much!
All the sessions of the conference are now available online