以下有數個查詢的例子:
// 找出 John Johnson 與其朋友共同看過的電影 match (u:User)-[:IS_FRIEND_OF]->()-[:HAS_SEEN]->(m:Movie) where u.name="John Johnson" and not((u)-[:HAS_SEEN]->(m)) return m as movie;
// 找出 John Johnson 的朋友看過的,但是 John Johnson 沒看過的電影 match (u:User)-[:IS_FRIEND_OF]->()-[:HAS_SEEN]->(m:Movie) where u.name="John Johnson" and (u)-[:HAS_SEEN]->(m) return m as movie;
// 找出大家看過的電影,剔除重複的電影 match (u:User)-[:HAS_SEEN]->(m:Movie) return distinct m as movie
// 找出 yearOfBirth 比 John Johnson 大的朋友 match (u1:User)-[:IS_FRIEND_OF]-(friend:User) where u1.name="John Johnson" and friend.yearOfBirth > u1.yearOfBirth return friend
// 找出 John Johnson 的朋友中,使用 gmail mailbox 的人 match (u1:User)-[:IS_FRIEND_OF]-(friend:User) where u1.name="John Johnson" and friend.email =~ ".*@gmail.com" return friend
// 找出每個人有幾個朋友 (數量以降冪排序) match (u:User)-[:IS_FRIEND_OF]-() return u as user, count(*) order by count(*) desc
// 找出 John Johnson 與其他節點的關係,並統計數量 match (u:User)-[rel]-() where u.name="John Johnson" with u.name as name, type(rel) as rel, count(*) as count return name, rel, count
No comments:
Post a Comment