2

For the following query:

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))

(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)

Why is that? (Using Neo4j 1.8.2)

Luanne
  • 19,145
  • 1
  • 39
  • 51

1 Answers1

3

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

more at https://github.com/neo4j/neo4j/blob/master/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/CHANGES.txt

ulkas
  • 5,748
  • 5
  • 33
  • 47