爲什麼這兩個查詢產生不同的結果:爲什麼我的Cypher查詢產生不同的結果?
MATCH (keanu:Person {name:"Keanu Reeves"})-[:ACTED_IN]->(kMovie)<-[:ACTED_IN]-(actor:Person),
(actor)-[:ACTED_IN]->()<-[:ACTED_IN]-(actor2)
WHERE NOT (actor2)-[:ACTED_IN]->(kMovie)
RETURN actor2.name, COUNT(actor2)
ORDER BY COUNT(actor2) DESC
LIMIT 3;
,第二個是:
MATCH (keanu:Person {name:"Keanu Reeves"})-[:ACTED_IN]->(kMovie)<-[:ACTED_IN]-(actor:Person),
(actor)-[:ACTED_IN]->()<-[:ACTED_IN]-(actor2)
WHERE NOT (actor2)-[:ACTED_IN]->()<-[:ACTED_IN]-(keanu)
AND keanu <> actor2
RETURN actor2.name, COUNT(actor2)
ORDER BY COUNT(actor2) DESC
LIMIT 3;
第二個給我正確的結果,但我不知道爲什麼第一個的結果是不同的?
第一結果:
╒═════════════╤═══════════════╕
│"actor2.name"│"COUNT(actor2)"│
╞═════════════╪═══════════════╡
│"Emil Eifrem"│"6" │
├─────────────┼───────────────┤
│"Tom Hanks" │"4" │
├─────────────┼───────────────┤
│"Stephen Rea"│"3" │
└─────────────┴───────────────┘
第二結果:
╒═════════════╤═══════════════╕
│"actor2.name"│"COUNT(actor2)"│
╞═════════════╪═══════════════╡
│"Tom Hanks" │"4" │
├─────────────┼───────────────┤
│"Stephen Rea"│"3" │
├─────────────┼───────────────┤
│"Ben Miles" │"3" │
└─────────────┴───────────────┘
數據集是可以從在Neo4j的示例的曲線圖部分被創建的示例電影圖形數據集。
請發佈兩個結果和原始數據集 –