创建唯一时,Cypher foreach似乎不会遍历集合 [英] Cypher foreach does not appear to iterate over collection when creating unique

查看:56
本文介绍了创建唯一时,Cypher foreach似乎不会遍历集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下查询:

START n=node(1) 
MATCH (n)-[:KNOWS]->(k), (n)-[:LOVES]->(l)
WITH collect(k) + collect(l) as friends, n
FOREACH(f in friends : create unique (n)-[:FRIEND]->(f))

(数据与console.neo4j.org相同) 我希望朋友是Morpheus和Trinity,所以从Neo到Morpheus和Neo到Trinity建立了新的FRIEND关系. 但是,在执行查询时,只会创建一个关系(Neo-[:FRIEND]-> Morpheus). 再次执行查询,并创建另一个关系(Neo-[:FRIEND]-> Trinity)

(Data is as on console.neo4j.org) I expect that friends are Morpheus and Trinity so a new FRIEND relation is created from Neo to Morpheus and Neo to Trinity. However, on executing the query, there is only one relation created (Neo-[:FRIEND]->Morpheus). Execute the query again and the other relation is created (Neo-[:FRIEND]->Trinity)

那是为什么? (使用Neo4j 1.8.2)

Why is that? (Using Neo4j 1.8.2)

推荐答案

我今天在变更日志中注意到这是一个错误,并且已在最新的1.9.M05版本中修复. Fixes #489 - CREATE UNIQUE does not work as expected inside FOREACH

i noticed today in the changelog that this was a bug and has been fixed in the newest 1.9.M05 version. Fixes #489 - CREATE UNIQUE does not work as expected inside FOREACH

更多信息,请参见 https://github.com/neo4j/neo4j/blob/master/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/CHANGES.txt

这篇关于创建唯一时,Cypher foreach似乎不会遍历集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆