在Neo4j中,Cypher是一種用于查詢和操作圖數(shù)據(jù)庫的語言
MATCH (a:Person)
RETURN a
UNION
MATCH (b:Person)
RETURN b
MATCH (a:Person {name: "Alice"})-[:KNOWS]->(b:Person)
RETURN a, b
MATCH (a:Person {name: "Alice"})-[:KNOWS]->(b:Person)
WITH a, b
MATCH (c:Person)-[:KNOWS]->(d:Person)
WHERE d IN (a, b)
RETURN c, d
MATCH (a:Person)
WHERE (
SIZE([(a)<-[:KNOWS]-(b:Person) | b]) > 2
)
RETURN a
MATCH (a:Person)
MATCH (b:Person)
RETURN a, b
MATCH (a:Person)-[:KNOWS]->(b:Person)
RETURN a, b
SKIP 10
LIMIT 5
MATCH (a:Person)-[:KNOWS]->(b:Person)
RETURN a, b
ORDER BY b.age DESC
MATCH (a:Person)-[:KNOWS]->(b:Person)
WITH a, COUNT(b) AS num_friends
RETURN a, num_friends
ORDER BY num_friends DESC
MATCH (a:Person)-[:KNOWS]->(b:Person)
WITH a, COUNT(b) AS num_friends
RETURN a, AVG(num_friends) AS avg_friends
這些示例展示了如何在Cypher中使用集合操作。您可以根據(jù)需要組合和調(diào)整這些操作以滿足您的查詢需求。