Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-08-2020 09:19 PM
First of all, I'm just starting with neo4j.
I have a database with nodes of type 'Candidate', 'JobPosition' and 'Skill', and given certain skills of a job position I want to recommend the best candidates for that position.
The problem is that the Candidate nodes have a 'birthDate' attribute and the JobPosition nodes have an 'ageRange' attribute, and I need to be considered in the recommendation when a candidate is within the ageRange.
I had thought about using APOC Jaccard or something similar, but how can I include the ageRange in the result, what is the most elegant way to do it?
Regards!
01-09-2020 12:53 AM
hey , you store starting age in the range as minAgeRequired and ending age in the range as maxAgeRequired and then do a query similar to the following
MATCH (j:JobPosition{matchprops...})-[:REQUIRES_SKILL]->(s:Skill)
WITH Date().year-j.minRequiredAge minYear, Date().year-maxRequiredAge as maxYear ,COLLECT(id(s)) as skills
MATCH (c:Candidate)-[:HAS_SKILL]->(s:Skill)
WHERE c.birthDate.year >=minYear OR c.birthDate.year <=maxYear
RETURN id(c) as candidateId, apoc.similarity.jaccard(skills, COLLECT(id(s)) as similarity ORDER BY similarity DESC LIMIT 1000
you can return any unique identifier you have instead of id(c) in the last line
01-09-2020 06:24 AM
Hi Ganesanmithun323! Thank you very much for the quick response!
The problem with that query is that the WHERE clause excludes candidates that are not within the ageRange.
I want that if the candidate is not within the agerRange it appears anyway in the recommendation but with a lower score.
I imagine a behavior similar to if there was a node 'Age' that share candidates and job position for example:
01-09-2020 07:10 AM
MATCH (j:JobPosition{matchprops...})-[:REQUIRES_SKILL]->(s:Skill)
WITH Date().year-j.minRequiredAge minYear, Date().year-maxRequiredAge as maxYear ,COLLECT(id(s)) as skills
MATCH (c:Candidate)-[:HAS_SKILL]->(s:Skill)
WITH c,COLLECT(id(s)) as candSkills , c.birthDate.year in RANGE (minYear,maxYear) as flag
WITH c, candSkills, CASE flag WHEN TRUE THEN 0 ELSE MIN(MIN(abs(maxAge-c.birthDate.year),abs(minYear,c.birthDate.year)),10 )END as distance
WITH id(c) as candidateId,distance,apoc.similarity.jaccard(skills, candSkills )as similarity ORDER BY similarity
RETURN candidateId,1-(distance/10)+similarity as totalScore ORDER BY totalScore DESC LIMIT 100
so, here when the people are in range , they get a distance 0 or min of distance from max or min age or 10 ..so people have more than 10 years from age range will be considered as 10 here but you can configure that and finally , we are normalising it to 1 and adding to jaccard score
check this out , https://github.com/graphaware/neo4j-reco ..
01-09-2020 09:58 AM
Thank you very much ganesanmithun323 is exactly what I was looking for, to be able to add to the jaccard score when the candidate is within the ageRange.
Thank you very much greetings!
01-09-2020 07:11 AM
you said age in range , right ? ..so , i assume that all people in that range are equally eligible for that job ..so , i think it would be wrong to convert the range to mean or something and mark it as just age
All the sessions of the conference are now available online