【问题标题】:neo4j how to compare two list and return the different itemsneo4j 如何比较两个列表并返回不同的项目
【发布时间】:2013-12-27 08:45:55
【问题描述】:

我正在使用neo4j MATCH 并获得两个用户列表:listA,listB, listBlistA
的一部分 如何仅在 listA 而不是在 listB 中返回用户使用 cipher query
密码喜欢:

匹配列表A,列表B
返回列表A - 列表B

这是我之前的问题:neo4j cypher multi relationship between nodes

完成查看以上链接中的解决方案

【问题讨论】:

  • 您链接到的答案可能已经解决了您的问题,但我看不出它是如何回答这个问题的

标签: neo4j


【解决方案1】:

要返回一个列表中不在另一个列表中的成员,您可以使用 FILTER 函数 (docs),例如

WITH [1,2,3,4,5,6] as listA, [1,2,3] as listB
RETURN FILTER( n IN listA WHERE NOT n IN listB ) as listC

c
4, 5, 6
Returned 1 row in 90 ms

【讨论】:

【解决方案2】:

过滤器功能在最新的 Neo4j 4.0 版本中被删除 doc here 相反,使用List comprehension

WITH [1,2,3,4,5,6] as listA, [1,2,3] as listB
RETURN [n IN listA WHERE NOT n IN listB] as listC

这会导致输出 4、5、6

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2020-07-07
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多