How to store ranges of date values and use them in a recommendation?

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!

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

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:

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 ..

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

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!