0

因此,我尝试从单个密码查询中返回 2 组:

给定父节点在索引中,则

  1. 父节点的子节点
  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"]                 |
==> +--------------------------------------------------------------+
4

1 回答 1

1

你可以试试这个 -

START Parents = node:app_fulltext('name:"City"'),
 MATCH Parents-[?:ChildOf]-Apps 
 WITH collect(Apps.Title) as myapps, collect(Parents.Name) as myparents
 RETURN myapps, filter(x in parents : not x in myapps) as myfilteredparents
于 2013-03-28T17:00:24.667 回答