variables - (Neo4j) 在后续查询中携带变量
问题描述
我试图通过 2 个后续查询来传递一个变量。似乎 WITH 仅有助于将变量传递到下一个查询,但在此之前没有任何作用。建议?
这是我正在尝试做的示例:
Person 节点包含有关出版商、作家和编辑的信息(例如姓名、性别等)
Story 节点包含有关 Story 的数据(例如标题、发布日期等)
IN 关系具有类别: 创建、编辑、发布。
返回编辑了其他编辑出版商发布的故事的编辑出版商:
假设没有重复的人名
- 查找所有编辑过至少一篇文章并发表过至少一篇文章的人
- 查找这些编辑出版商发表的故事列表 1
- 在 2 中故事的所有编辑器中,返回这些编辑器的子列表也在 1 中
MATCH (EditorPublisher:Person)-[:IN{category: "published"}]->(:Story) // 1
WHERE (EditorPublisher:Person)-[:IN{category: "edited"}]->(:Story)
WITH COLLECT(EditorPublisher.name) as EditorPublisher_list
MATCH (EditorPublisher_stories:Story)<-[:IN{category: "published"}]-(publisher:Person) // 2
WHERE publisher.name in EditorPublisher_list
WITH EditorPublisher_list // throws error EditorPublisher_list variable not found
WITH COLLECT(EditorPublisher_stories.title) as EditorPublisher_stories_list
MATCH (epe:Person)-[contribution:PLAYED]-(eps:Movie) // 3
WHERE epe.name in EditorPublisher_list
AND eps IN EditorPublisher_stories_list
RETURN epe.name
解决方案
NVM 我让它工作。如果我不重命名变量,With 会保留变量。
我只需要做 WITH return.nodes,并在后续查询中调用 return.nodes 而不是在 [return.nodes.list] 中使用
推荐阅读
- c++ - 如何强制编译器显示隐式构造函数
- javascript - 在velocity.js 最新更新(2.0.3)后无法读取属性“模式”错误
- python - 进程以退出代码 -1073740791 (0xC0000409) pycharm 错误完成
- php - Uncaught ImagickException: UnableToOpenBlob `application/pdf': 没有这样的文件或目录
- php - 如何从前端编辑或更新 wordpress 自定义数据库表?
- java - RabbitMQ 连接重置
- module - 如何在子模块中使用在模块中创建的异常(在 ocaml 中)
- android - Gradle 构建工具找不到 play-services-tasks.aar?为什么?
- ckeditor - 如何在 CKEditor 5 中禁用放置事件
- apache-spark - 如何使用 http 请求查询 Hive/Spark Thrift Server