获取未收集的节点

时间:2017-06-09 11:32:02

标签: neo4j cypher

我想要那些名称不在a_row集合中的节点。例如:b,c拥有b_row,将a_rowb_row b,c,e合并后,entity.name正在a,b,c,da,d正在match (a)-[r:relations]->(b) with collect(distinct a.FirstName) as a_row match (a)-[r:relations]->(b) with a_row + collect(distinct b.LastName) as b_row match (n:entity) with b_row where n.name <> b_row return n 。所以我希望节点形式的输出0xF不在列表表单中。

0b1111

提前致谢,如果需要进一步的信息,请与我们联系。

2 个答案:

答案 0 :(得分:0)

尝试按IN operator更改<>。这样:

match (a)-[r:relations]->(b) with collect(distinct a.FirstName) as a_row
match (a)-[r:relations]->(b) with a_row + collect(distinct b.LastName) as b_row
match (n:entity) where n.name NOT IN b_row return n

答案 1 :(得分:0)

第一

match (a)-[r:relations]->(b) with collect(distinct a.FirstName) as a_row
match (a)-[r:relations]->(b) with a_row + collect(distinct b.LastName) as b_row
match (n:entity) with b_row where n.name <> b_row return n

无效,因为最后with会丢弃n,并且可以简化为

MATCH (a)-[r:relations]->(b) 
WITH collect(distinct a.FirstName)+collect(distinct b.LastName) as b_row
MATCH (n:entity)
// b_row in now a list, so if n.name is a string, <> is always false
WHERE n.name NOT IN b_row 
RETURN n

我将简化为

MATCH (a)-[r:relations]->(b) 
WITH collect(distinct a.FirstName)+collect(distinct b.LastName) as b_row
MATCH (n:entity)
RETURN n, b_row

首先验证您的查询是否在过滤之前提升了您的想法。