I am working on an HR analytics projects using neo4j and I encountered a complicated query (I am also very new to cypher). Basically, I have a list of employee with some features like location, skill set, education and positions with location, skills required. I look if location (employee’s location and position’s location) matches and set that score to 1 (0 otherwise). If I have only one open position, the query works fine. However, with more positions the variable gets overwritten with last value of last position. I would imagine putting the node properties in an array but doesn’t seem that cypher has that (deprecated).
https://neo4j.com/docs/rest-docs/current/#rest-api-property-values
This is the query that I use and I would be grateful if you can help me resolve the issue. Final goal is to have a score for every employee per a given position and fill the position with the employee with highest score. Is this even possible on cypher?? Thanks a lot
MATCH
(e:Employee)-[r:FUTURE_POSITION]-> (p:Position {open_status:1}),
(e)-[h:HAS_DEGREE]-> (d:Degree),
(e)-[s:HAS_SKILL]-> (n:Personal_Skill)
WITH r, e,p,d,n,
CASE WHEN p.position_state = e.home_state THEN 1 ELSE 0 END AS SameStateScore,
CASE WHEN p.position_city = e.home_city THEN 1 ELSE 0 END AS SameCityScore,
CASE WHEN d.name = "College Degree" THEN 1 ELSE 0 END AS HasCollegeDegree,
CASE WHEN n.name = "Management" THEN 1 ELSE 0 END AS HasRequiredSkill
SET e.score = SameStateScore + SameCityScore + HasCollegeDegree + HasRequiredSkill
RETURN DISTINCT e.name,p.name, SameStateScore,SameCityScore,HasCollegeDegree,MAX(HasRequiredSkill) AS HasRequiredSkill, e.score
ORDER BY e.score DESC