为了提取随机图,我使用:
// assume already matched to start node n
MATCH r = (n)-[:I]-()
WITH apoc.coll.randomItems(collect(r), 10) as r1
UNWIND r1 as r
WITH r1, last(nodes(r)) as n
MATCH r = (n)-[:I]-()
WITH r1, apoc.coll.randomItems(collect(r), 10) as r2
UNWIND r2 as r
WITH r1, r2, last(nodes(r)) as n
MATCH r = (n)-[:I]-()
WITH r1, r2, apoc.coll.randomItems(collect(r), 10) as r3
UNWIND r3 as r
WITH r1, r2, r3, last(nodes(r)) as n
MATCH r = (n)-[:I]-()
WITH r1, r2, r3, apoc.coll.randomItems(collect(r), 10) as r4
RETURN r1 + r2 + r3 + r4
但我想添加一个约束:
MATCH r = (n)-[z:I]-()
WHERE z.grow CONTAINS "xxx"
WITH apoc.coll.randomItems(collect(r), 10) as r1
但它不起作用。事实上,它就像没有约束一样。
此外,
MATCH r = (n)-[:I]-()
WHERE r.grow CONTAINS "xxx"
WITH apoc.coll.randomItems(collect(r), 10) as r1
不明白。
可以添加这样的约束吗?