forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive-complex-1.cypher
52 lines (52 loc) · 1.53 KB
/
interactive-complex-1.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Q1. Transitive friends with certain name
/*
:param [{ personId, firstName }] => { RETURN
4398046511333 AS personId,
"Jose" AS firstName
}
*/
MATCH p=shortestPath((person:Person {id: $personId})-[path:KNOWS*1..3]-(friend:Person {firstName: $firstName}))
WHERE person <> friend
WITH friend, length(p) AS distance
ORDER BY distance ASC, friend.lastName ASC, friend.id ASC
LIMIT 20
MATCH (friend)-[:IS_LOCATED_IN]->(friendCity:City)
OPTIONAL MATCH (friend)-[studyAt:STUDY_AT]->(uni:Organisation)-[:IS_LOCATED_IN]->(uniCity:City)
WITH
friend,
collect(
CASE uni.name
WHEN NULL THEN NULL
ELSE [uni.name, studyAt.classYear, uniCity.name]
END
) AS unis,
friendCity,
distance
OPTIONAL MATCH (friend)-[workAt:WORK_AT]->(company:Organisation)-[:IS_LOCATED_IN]->(companyCountry:Country)
WITH
friend,
collect(
CASE company.name
WHEN NULL THEN NULL
ELSE [company.name, workAt.workFrom, companyCountry.name]
END
) AS companies,
unis,
friendCity,
distance
RETURN
friend.id AS friendId,
friend.lastName AS friendLastName,
distance AS distanceFromPerson,
friend.birthday AS friendBirthday,
friend.creationDate AS friendCreationDate,
friend.gender AS friendGender,
friend.browserUsed AS friendBrowserUsed,
friend.locationIP AS friendLocationIp,
friend.email AS friendEmails,
friend.speaks AS friendLanguages,
friendCity.name AS friendCityName,
unis AS friendUniversities,
companies AS friendCompanies
ORDER BY distanceFromPerson ASC, friendLastName ASC, friendId ASC
LIMIT 20