因此,我尝试从单个密码查询中返回 2 组:
给定父节点在索引中,则
- 父节点的子节点
- 无子父节点。
我能够得到一个类似的查询,该查询返回一组索引中的父母和另一组索引中的孩子,如下所示
START Parents = node:app_fulltext('name:"City"'),
MATCH Parents-[?:ChildOf]-Apps
RETURN collect(Apps.Title), collect(Parents.Name);
==> +--------------------------------------------------------------+
==> | collect(Apps.Title) | collect(Parents.Name) |
==> +--------------------------------------------------------------+
==> | ["Empty City 3D"] | ["Empty City 3D","Empty City 3D Fake"] |
==> +--------------------------------------------------------------+
这接近我想要的。但是,我想从 Parents.Name 中过滤掉那些在 Apps.Title 集合中已经有 Children 的项目。
这是我想要得到的结果集。“Empty City 3D Fake”没有任何子元素,因此在 Parents.Name 中返回。
==> +--------------------------------------------------------------+
==> | collect(Apps.Title) | collect(Parents.Name) |
==> +--------------------------------------------------------------+
==> | ["Empty City 3D"] | ["Empty City 3D Fake"] |
当我刚刚添加 Where r is null 子句时,它没有返回任何内容,因此我最终不得不添加两个相同的起始父集(Parents 和 Parents2)来执行此操作。但是,这看起来真的很笨拙,所以我希望有更好的方法。
START Parents = node:app_fulltext('name:"City"'),
Parents2 = node:app_fulltext('name:"City"')
MATCH Parents-[r?:ChildOf]-Children, Parents2-[:ChildOf]-Apps
Where r is null
return collect(Apps.Title), collect(Parents.Name);
==> +--------------------------------------------------------------+
==> | collect(Apps.Title) | collect(Parents.Name) |
==> +--------------------------------------------------------------+
==> | ["Empty City 3D"] | ["Empty City 3D Fake"] |
==> +--------------------------------------------------------------+