There is the following schema:
Person-[:HAS]->(:Skill)<-[:REQUIRES]-(:Job)
Job requires some number of Skills. How to properly with Cypher MATCH Person which has ALL of the Skills required by some certain Job?
There is the following schema:
Person-[:HAS]->(:Skill)<-[:REQUIRES]-(:Job)
Job requires some number of Skills. How to properly with Cypher MATCH Person which has ALL of the Skills required by some certain Job?
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:
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