Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-10-2020 08:44 AM
Stuck with a query today and wonder if someone wants to help out?
MATCH (visitor:User)-[:VISIT]->(visit:Visit)-[:VISIT]->(user:User)
WHERE (user.UserId = "xxx")
This is the pattern I am starting with. Want a list of visitors that visited user with UserId. Every Visit has a date and I need to get a list with the 10 last visits, but all those visits need to have unique visitors. Not sure how to use distinct to get what I need
Thanks a lot
Solved! Go to Solution.
06-11-2020 03:32 AM
Opted to change the data model so only one visit node is created between 2 users and later updated with number of visits and earlier visits list. Makes sense from many perspectives and means no complicated database queries needed
06-10-2020 09:16 AM
Try this:
MATCH (user:User)-[:VISIT]->((visit:Visit)
WHERE (user.UserId = "xxx")
with user, visit
MATCH (visitor:User)-[:VISIT]->(visit)
WHERE visitor.UserId <> user.UserId
RETURN visitor, visit
06-10-2020 09:57 AM
Thanks a lot for your suggestion Definitely think this could be a step in the right direction but I also need to make sure to return 10 unique visitors only with their last visit based on visit.Date.
06-11-2020 03:32 AM
Opted to change the data model so only one visit node is created between 2 users and later updated with number of visits and earlier visits list. Makes sense from many perspectives and means no complicated database queries needed
All the sessions of the conference are now available online