forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bi-10.cypher
38 lines (38 loc) · 1.19 KB
/
bi-10.cypher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Q10. Central Person for a Tag
/*
:param {
tag: 'John_Rhys-Davies',
date: 20120122000000000
}
*/
MATCH (tag:Tag {name: $tag})
// score
OPTIONAL MATCH (tag)<-[interest:HAS_INTEREST]-(person:Person)
WITH tag, collect(person) AS interestedPersons
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(person:Person)
WHERE message.creationDate > $date
WITH tag, interestedPersons + collect(person) AS persons
UNWIND persons AS person
// poor man's disjunct union (should be changed to UNION + post-union processing in the future)
WITH DISTINCT tag, person
WITH
tag,
person,
100 * length([(tag)<-[interest:HAS_INTEREST]-(person) | interest])
+ length([(tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(person) WHERE message.creationDate > $date | message])
AS score
OPTIONAL MATCH (person)-[:KNOWS]-(friend)
WITH
person,
score,
100 * length([(tag)<-[interest:HAS_INTEREST]-(friend) | interest])
+ length([(tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(friend) WHERE message.creationDate > $date | message])
AS friendScore
RETURN
person.id,
score,
sum(friendScore) AS friendsScore
ORDER BY
score + friendsScore DESC,
person.id ASC
LIMIT 100