Cypher查询匹配所有路径

时间:2013-04-08 09:19:35

标签: neo4j cypher

我有一个包含“项目”,“员工”和“技术”等节点的图表。项目与技术之间以及员工与技术之间存在关联。

我想找到了解项目所用技术的员工。我的cyper-query看起来像这样:

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

运行此查询时,我会让所有员工了解项目使用的一种技术,并希望员工了解项目使用的所有技术。这在密码中是否可行?

2 个答案:

答案 0 :(得分:3)

您可以尝试以下内容:

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

请参阅Finding nodes that have all common intermediaries

答案 1 :(得分:2)

我可能会使用它来避免计算每个员工项目使用的技术数量:

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