Created
June 24, 2012 16:05
-
-
Save mneedham/2983831 to your computer and use it in GitHub Desktop.
neo4j query to find thoughtworks colleagues of colleagues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START n = node(*) | |
MATCH n-[r:colleagues*1..2]->c, n-[r2:member_of]->office | |
WHERE n.type? = 'person' and has(n.name) and (not(has(r2.end_date))) and office.name = 'London - UK South' and (not(has(c.thoughtquitter))) | |
RETURN n.name, count(distinct(c)) AS connections, office.name | |
ORDER BY connections DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ahhh ok. What I actually want to do is find out how many offices people who are currently working in the London office have worked at.
If I add a relationship called 'current_office' and then have the query:
START office=node:offices(name='London - UK South')
MATCH office<-[r:current_office]-person, person-[r2?:member_of]->other
WHERE (NOT(HAS(r.end_date)))
RETURN person, COUNT(DISTINCT(other))
Will that return a different result or will it be the same because the office & person nodes are still bound?
If that's the case is there any way you can think for me to do this query?