LDBC Query1 converted

Summary: Ugly formatting and bad variable naming due to 1024 limit on neo4j client.

Reviewers: buda, teon.banek

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D748
This commit is contained in:
florijan 2017-09-07 15:31:37 +02:00
parent 38c83d80cb
commit 63966c15a6
3 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Person,Name
30786325583618,Chau

View File

@ -0,0 +1,45 @@
MATCH (:Person {id:"30786325583618"})-[p:KNOWS*1..3]-(f:Person)
WHERE f.firstName = "Chau"
WITH f, min(length(p)) AS d
ORDER BY d ASC, f.lastName ASC, toint(f.id) ASC
LIMIT 20
MATCH (f)-[:IS_LOCATED_IN]->(fCity:Place)
OPTIONAL MATCH (f)-[studyAt:STUDY_AT]->(uni:Organisation)-[:IS_LOCATED_IN]->(uniCity:Place)
WITH
f,
collect(
CASE uni.name
WHEN null THEN null
ELSE [uni.name, studyAt.classYear, uniCity.name]
END
) AS unis,
fCity,
d
OPTIONAL MATCH (f)-[worksAt:WORK_AT]->(c:Organisation)-[:IS_LOCATED_IN]->(cCountry:Place)
WITH
f,
collect(
CASE c.name
WHEN null THEN null
ELSE [c.name, worksAt.workFrom, cCountry.name]
END
) AS companies,
unis,
fCity,
d
RETURN
f.id AS id,
f.lastName AS lastName,
d as distance,
f.birthday AS birthday,
f.creationDate AS creationDate,
f.gender AS gender,
f.browserUsed AS browser,
f.locationIP AS locationIp,
f.email AS emails,
f.speaks AS languages,
fCity.name AS cityName,
unis,
companies
ORDER BY distance ASC, f.lastName ASC, toint(f.id) ASC
LIMIT 20;

View File

@ -0,0 +1,45 @@
MATCH (:Person {id:"30786325583618"})-[p:KNOWS*1..3]-(f:Person)
WHERE f.firstName = "Chau"
WITH f, min(size(p)) AS d
ORDER BY d ASC, f.lastName ASC, tointeger(f.id) ASC
LIMIT 20
MATCH (f)-[:IS_LOCATED_IN]->(fCity:Place)
OPTIONAL MATCH (f)-[studyAt:STUDY_AT]->(uni:Organisation)-[:IS_LOCATED_IN]->(uniCity:Place)
WITH
f,
collect(
CASE uni.name
WHEN null THEN null
ELSE [uni.name, studyAt.classYear, uniCity.name]
END
) AS unis,
fCity,
d
OPTIONAL MATCH (f)-[worksAt:WORK_AT]->(c:Organisation)-[:IS_LOCATED_IN]->(cCountry:Place)
WITH
f,
collect(
CASE c.name
WHEN null THEN null
ELSE [c.name, worksAt.workFrom, cCountry.name]
END
) AS companies,
unis,
fCity,
d
RETURN
f.id AS id,
f.lastName AS lastName,
d as distance,
f.birthday AS birthday,
f.creationDate AS creationDate,
f.gender AS gender,
f.browserUsed AS browser,
f.locationIP AS locationIp,
f.email AS emails,
f.speaks AS languages,
fCity.name AS cityName,
unis,
companies
ORDER BY distance ASC, f.lastName ASC, tointeger(f.id) ASC
LIMIT 20;