1

I have a graph with nodes like "project", "employee" and "technology". There are relations between project and technology and between employee and technology.

I want to find employees that know all the technology used by a project. My cyper-query looks like this:

start project=node:project(name = "Project1") 
match technology <-[:USED]- project , employee -[:KNOWS]-> technology 
return employee

When running this query I get all employees that know one technology used by the project, and want employees that know all technologies used by the project. Is this possible in cypher?

olemartin
  • 137
  • 1
  • 7

2 Answers2

3

You can try something like:

start project=node:project(name = "Project1") 
match employee -[:KNOWS]-> technology <-[:USED]- project 
with count(technology) as knownTech, employee, project
where length(()<-[:USED]-project)=knownTech
return employee

See Finding nodes that have all common intermediaries

Community
  • 1
  • 1
Luanne
  • 19,145
  • 1
  • 39
  • 51
  • Great, thanks! There's an extra parenthese after project in the where clause though. Other than that, great! Btw, had to upgrade neoclipse in order to use with and where, I had a version from 2012. – olemartin Apr 08 '13 at 11:47
2

I would probably use this to avoid computing the number of technologies used by the project per employee:

start project=node:project(name = "Project1") 
match technology <-[:USED]- project 
with count(technology) as projectTech, project
match employee -[:KNOWS]-> technology <-[:USED]- project 
with count(technology) as knownTech, projectTech, employee
where projectTech=knownTech
return employee
Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
  • That makes sense, didn't think of it. I re-wrote some of my queries after http://stackoverflow.com/questions/14657265/finding-nodes-that-have-all-common-intermediaries/14662744#14662744 but now I see that this one is more efficient, thanks – Luanne Apr 09 '13 at 07:20