Skip to end of metadata
Go to start of metadata

QUERY 1

MATCH (:Person {id:{person_id}})-[path:KNOWS*]-(friend:Person)
WHERE friend.firstName = {friend_first_name}
WITH friend, min(length(path)) AS distance
ORDER BY distance ASC, friend.lastName ASC
LIMIT {limit}
OPTIONAL MATCH (friend)-[:IS_LOCATED_IN]->(friendCity:City)
OPTIONAL MATCH (friend)-[studyAt:STUDY_AT]->(uni:University)-[:IS_LOCATED_IN]->(uniCity:City)
WITH friend, collect(uni.name + ',' + uniCity.name + ',' + studyAt.classYear) AS unis, friendCity, distance
OPTIONAL MATCH (friend)-[worksAt:WORKS_AT]->(company:Company)-[:IS_LOCATED_IN]->(companyCountry:Place:Country)
WITH friend, collect(company.name + ',' + companyCountry.name + ',' + worksAt.workFrom) AS companies, unis, friendCity, distance
RETURN friend.id AS id, friend.lastName AS lastName, distance, friend.birthday AS birthday, friend.creationDate AS creationDate, friend.gender AS gender, friend.browserUsed AS browser, friend.locationIP AS locationIp,
  friend.email AS emails, friend.languages AS languages, friendCity.name AS cityName, unis, companies
ORDER BY distance ASC, friend.lastName ASC
LIMIT {limit}

QUERY 2

MATCH (:Person {id:{person_id}})-[:KNOWS]-(friend:Person)<-[:HAS_CREATOR]-(post:Post)
WHERE post.creationDate <= {max_date}
RETURN friend.id AS personId, friend.firstName AS personFirstName, friend.lastName AS personLastName, post.id AS postId, post.content AS postContent, post.creationDate AS postDate
ORDER BY postDate DESC
LIMIT {limit}

QUERY 3

MATCH (person:Person {id:{person_id}})-[:KNOWS*1..2]-(friend:Person)<-[:HAS_CREATOR]-(postX:Post)-[:IS_LOCATED_IN]->(countryX:Country)
WHERE countryX.name={country_x} AND postX.creationDate>={min_date} AND postX.creationDate<={max_date}
WITH friend, count(DISTINCT postX) AS xCount
MATCH (friend)<-[:HAS_CREATOR]-(postY:Post)-[:IS_LOCATED_IN]->(countryY:Country {name:{country_y}})
WHERE postY.creationDate>={min_date} AND postY.creationDate<={max_date}
WITH friend.firstName + ' ' + friend.lastName AS friendName , xCount, count(DISTINCT postY) AS yCount
RETURN friendName, xCount, yCount, xCount + yCount AS xyCount
ORDER BY xyCount DESC
LIMIT {limit}

QUERY 4

MATCH (person:Person {id:{person_id}})-[:KNOWS]-(friend:Person)<-[:HAS_CREATOR]-(post:Post)-[HAS_TAG]->(tag:Tag)
WHERE post.creationDate >= {min_date} AND post.creationDate <= {max_date}
WITH DISTINCT tag, collect(tag) AS tags
RETURN tag.name AS tagName, length(tags) AS tagCount
ORDER BY tagCount DESC
LIMIT {limit}

QUERY 5

MATCH (person:Person {id:{person_id}})-[:KNOWS*1..2]-(friend:Person)<-[membership:HAS_MEMBER]-(forum:Forum)
WHERE membership.joinDate>{join_date}
MATCH (friend)<-[:HAS_CREATOR]-(post:Post)<-[:CONTAINER_OF]-(forum)
RETURN forum.title AS forum, count(post) AS postCount
ORDER BY postCount DESC

QUERY 6

MATCH (person:Person {id:{person_id}})-[:KNOWS*1..2]-(:Person)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(:Tag {name:{tag_name}})
WITH DISTINCT post
MATCH (post)-[:HAS_TAG]->(tag:Tag)
WHERE NOT(tag.name={tag_name})
RETURN tag.name AS tagName, count(tag) AS tagCount
ORDER BY tagCount DESC
LIMIT {limit}

QUERY 7

MATCH (start:Person {id:{person_id}})<-[:HAS_CREATOR]-(post:Post)<-[like:LIKES]-(person:Person)
RETURN person.id AS personId, person.firstName AS personFirstName, person.lastName AS personLastName, like.creationDate AS likeDate, NOT((person)-[:KNOWS]-(start)) AS isNew, post.id AS postId,
  post.content AS postContent, like.creationDate - post.creationDate AS latency
ORDER BY like.creationDate DESC, personId ASC
LIMIT {limit}

QUERY 8

MATCH (:Person {id:{person_id}})<-[:HAS_CREATOR]-(post:Post)
MATCH (post)<-[:REPLY_OF*]-(comment:Comment)-[:HAS_CREATOR]->(person:Person)
RETURN person.id AS personId, person.firstName AS personFirstName, person.lastName AS personLastName, comment.id AS commentId, comment.creationDate AS commentCreationDate, comment.content AS commentContent
ORDER BY commentCreationDate DESC, commentId ASC
LIMIT {limit}

QUERY 9

MATCH (:Person {id:{person_id}})-[:KNOWS*1..2]-(friend:Person)
MATCH (friend)<-[:HAS_CREATOR]-(activity) WHERE activity.creationDate < {latest_date}
RETURN DISTINCT activity.id AS activityId, activity.content AS activityContent, activity.creationDate AS activityCreationDate, friend.id AS personId, friend.firstName AS personFirstName, friend.lastName AS personLastName
ORDER BY activity.creationDate DESC, activity.id ASC
LIMIT {limit}

QUERY 10

MATCH (person:Person {id:{person_id}})
MATCH (person)-[:KNOWS*2..2]-(friend:Person)-[:IS_LOCATED_IN]->(city:City)
WHERE friend.birthday_month >= {horoscope_month_min} AND friend.birthday_month < {horoscope_month_max}
OPTIONAL MATCH (friend)<-[:HAS_CREATOR]-(post:Post)
WITH friend, city.name AS personCityName, count(post) AS allPostCount, person
OPTIONAL MATCH (friend)<-[:HAS_CREATOR]-(post:Post)
WHERE (post)-[:HAS_TAG]->(:Tag)<-[:HAS_INTEREST]-(person)
WITH friend, personCityName, allPostCount, count(post) AS commonPostCount
RETURN friend.id AS personId, friend.firstName AS personFirstName, friend.lastName AS personLastName, friend.gender AS personGender, personCityName,
  CASE allPostCount
    WHEN 0 THEN 0.0
    ELSE commonPostCount / (allPostCount + 0.0)
  END AS commonInterestScore
ORDER BY commonInterestScore DESC, personId ASC
LIMIT {limit} 

QUERY 11

MATCH (:Person {id:{person_id}})-[:KNOWS*1..2]-(friend:Person)
WITH DISTINCT friend
MATCH (friend)-[worksAt:WORKS_AT]->(company:Company)
WHERE worksAt.workFrom <= {work_from_year} AND (company)-[:IS_LOCATED_IN]->(:Country {name:{country_name}})
RETURN friend.id AS friendId, friend.firstName AS friendFirstName, friend.lastName AS friendLastName, worksAt.workFrom AS workFromYear, company.name AS companyName
ORDER BY workFromYear ASC, friendId ASC
LIMIT {limit}

QUERY 12

MATCH (:Person {id:{person_id}})-[:KNOWS]-(friend:Person)
OPTIONAL MATCH (friend)<-[:HAS_CREATOR]-(comment:Comment)-[:REPLY_OF*]->()-[:HAS_TAG]->(tag:Tag)-[:HAS_TYPE]->(tagClass:TagClass)-[:IS_SUBCLASS_OF*0..]->(baseTagClass:TagClass)
WHERE tagClass.uri = {tag_class_id} OR baseTagClass.uri = {tag_class_id}
RETURN friend.id AS friendId, friend.firstName AS friendFirstName, friend.lastName AS friendLastName, collect(DISTINCT tag.name) AS tagNames, count(DISTINCT comment) AS count
ORDER BY count DESC, friendId ASC
LIMIT {limit}

QUERY 13

MATCH path = shortestPath((person1:Person {id:{person_id_1}})-[:KNOWS]-(person2:Person {id:{person_id_2}}))
RETURN length(path) AS pathLength

QUERY 14

MATCH path = (person1:Person {id:{person_id_1}})<-[:HAS_CREATOR]-()-[r:REPLY_OF*0..]-()-[:HAS_CREATOR]->(person2:Person {id:{person_id_2}})
WHERE all(message IN [n IN nodes(path) WHERE not(n:Person)] WHERE (message)-[:HAS_CREATOR]->(person1) OR (message)-[:HAS_CREATOR]->(person2))
RETURN
  [n IN nodes(path) | [labels(n)[0], n.id]] AS pathNodes,
  reduce(weight = -0.5, n IN nodes(path) |
    CASE labels(n)[0]
      WHEN 'Post' THEN weight + 1.0
      WHEN 'Comment' THEN weight + 0.5
      ELSE weight
    END) AS weight
ORDER BY length(pathNodes) ASC, weight DESC
LIMIT {limit}

  • No labels