Databases Reference
In-Depth Information
Finding colleagues with particular interests
In the second Talent.net use case, we turn from inferring social relations based on shared
interests to finding individuals who have a particular skillset, and who have either
worked with the person who is the subject of the query, or worked with people who
have worked with the subject. By applying the graph in this manner, we can find indi‐
viduals to staff project roles based on their social ties to people we trust—or at least have
worked with.
The social ties in question arise from individuals having worked on the same project.
Contrast this with the previous use case, where the social ties were inferred based on
shared interests. If people have worked on the same project, we infer a social tie. The
projects, then, form intermediate nodes that bind two or more people together: they are
instances of collaboration that have brought people into contact with one another. Any‐
one we discover in this fashion is a candidate for including in our results—as long as
they possess the interests or skills we are looking for.
Here's a Cypher query that finds colleagues, and colleagues-of-colleagues, who have one
or more particular interests:
START subject= node :user(name= {name} )
MATCH p=(subject)-[:WORKED_ON]->()-[:WORKED_ON*0..2]-()
<-[:WORKED_ON]-(person)-[:INTERESTED_IN]->(interest)
WHERE person<>subject AND interest.name IN {interests}
WITH person, interest, min ( length (p)) as pathLength
RETURN person.name AS name,
count (interest) AS score,
collect (interest.name) AS interests,
((pathLength - 1)/2) AS distance
ORDER BY score DESC
LIMIT {resultLimit}
This is quite a complex query. Let's break it down little, and look at each part in more
detail:
START looks up the subject of the query in the user index, and assigns the result to
the subject identifier.
MATCH finds people who are connected to the subject by way of having worked on
the same project, or having worked on the same project as people who have worked
with the subject . For each person we match, we capture his interests. This match
is then further refined by the WHERE clause, which excludes nodes that match the
subject of the query, and ensures we only match people who are interested in the
things we care about. For each successful match, we assign the entire path of the
match—that is, the path that extends from the subject of the query all the way
through the matched person to his interest—to the identifier p . We'll look at this
MATCH clause in more detail shortly.
Search WWH ::




Custom Search