Skip to content

Commit

Permalink
Rewrite IC 6 with cypher (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu authored Jan 31, 2023
1 parent 7b1ea35 commit 8635dc4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions nebula/queries/interactive-complex-6.ngql
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
GO 1 to 2 steps from $personId over KNOWS bidirect where KNOWS._dst <> $personId yield distinct KNOWS._dst as friend |
GO from $-.friend over POST_HAS_CREATOR reversely yield distinct POST_HAS_CREATOR._dst as friendPost |
GO from $-.friendPost over HAS_TAG where $$.`Tag`.name==$tagName yield distinct HAS_TAG._src as postWithSpecifiedTag |
GO from $-.postWithSpecifiedTag over HAS_TAG where $$.`Tag`.name<>$tagName yield distinct $$.`Tag`.name as otherTagName, HAS_TAG._src as commonPost |
group by $-.otherTagName yield $-.otherTagName as otherTagName, count($-.commonPost) as postCount |
order by $-.postCount desc, $-.otherTagName ASC |
limit 10
MATCH (person:Person)-[:KNOWS*1..2]-(friend:Person)
WHERE id(person) == $personId AND id(friend) != $personId
WITH DISTINCT friend
MATCH (knownTag:`Tag`{name: $tagName})<-[:HAS_TAG]-(post:Post),
(post)-[:POST_HAS_CREATOR]->(friend:Person),
(post)-[:HAS_TAG]->(t:`Tag`)
WHERE t.`Tag`.name != $tagName
RETURN t.`Tag`.name AS tagName, count(id(post)) AS postCount
ORDER BY postCount DESC, tagName ASC
LIMIT 10

0 comments on commit 8635dc4

Please sign in to comment.