Neo4j Cypher 查询包括起始节点

标签 neo4j cypher

我想列出我演过的所有电影以及每部电影中 Actor 的总和,但下面的查询仅返回除我之外的 Actor 总和,不会返回没有其他 Actor 的电影。

start me=node({0}) 
match me-[:ACTS_IN]->movie<-[:ACTS_IN]-otherActors 
return movie, count(*) as actorSum

最佳答案

您需要使用WITH将其分解。您的查询的问题在于您在 match 的第一部分声明了 me 节点,因此 me 永远不可能在otherActors中。

start me=node({0}) 
match me-[:ACTS_IN]->movie
with movie   
match movie<-[:ACTS_IN]-actors 
return movie, count(*) as actorSum

关于Neo4j Cypher 查询包括起始节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18691667/

相关文章:

python - neo4j中节点之间的循环关系

neo4j - Cypher Neo4j ORDER BY DESC查询

neo4j - 无法删除 Neo4j 中的节点标签

Neo4j - 根据标签获取电影推荐

php - Laravel NeoEloquent 忽略 "CONSTRAINT"on::create 命令

mysql - 将图形数据库加入 RDBMS?

Spring Neo4j不保存数据

java - Neo4j + Postgres 共同事务

neo4j - 按列表中的元素过滤的模式?

csv - neo4j:mac 上的文件路径(导入 csv 文件)