简体   繁体   English

Neo4j Cypher 全部匹配

[英]Neo4j Cypher Match all

There is the following schema:有以下架构:

Person-[:HAS]->(:Skill)<-[:REQUIRES]-(:Job)

Job requires some number of Skills . Job需要一些Skills How to properly with Cypher MATCH Person which has ALL of the Skills required by some certain Job ?如何正确使用Person MATCH具有某些Job所需的ALL Skills的人?

Try this, here we collect skills of the job and the person skills in different collections and then we check if all the skills for the job, are present in the persons skill collection:试试这个,在这里我们收集不同 collections 中的工作技能和个人技能,然后我们检查工作的所有技能是否存在于个人技能集合中:

MATCH (j:Job)-[:REQUIRES]->(s:Skill)
WITH j, collect(DISTINCT s) AS skillsRequiredForTheJob
MATCH (p:Person)-[:HAS]->(s:Skill)
WITH j, p, skillsRequiredForTheJob, collect(DISTINCT s) AS personSkills
WHERE ALL(skill IN skillsRequiredForTheJob WHERE skill IN personSkills)
RETURN p 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM