Reputation: 571
neo4j is neo4j community edition, version 3.1.1
I create a node for a LUN
merge ( l3:lun {nom:"OS_SU1_", serie:"123456", coordonnees:"00:00:00"})
set l3.taille = 102400
latter on, I want to connect a host to this LUN, creating host is easy
merge (hSUP_1:host {nom:"SUP_1"})
now the big deal, I want to find l by its coordinate and create the relationship, I tried
match (l:lun {coordonnees : "00:00:00"}) merge (hSUP_1) -[:connecte_a]-> (l)
and get an error:
WITH is required between MERGE and MATCH (line ...)
(I cannot keep l3
identifier above, those lines are generated by a script that parse different file)
what is correct syntax ?
man page searched : neo4j.com/docs/developer-manual/current/cypher/clauses/merge/ (3.3.8.4. Merge relationships )
Upvotes: 2
Views: 111
Reputation: 7458
Yop,
You can't make a MATCH after a MERGE,so you have to add a WITH between like this :
MERGE (hSUP_1:host {nom:"SUP_1"})
MATCH (l:lun {coordonnees : "00:00:00"})
WITH l, hSUP
MERGE (hSUP_1) -[:connecte_a]-> (l)
Otherwise, you can also change the order like this :
MATCH (l:lun {coordonnees : "00:00:00"})
MERGE (hSUP_1:host {nom:"SUP_1"})
MERGE (hSUP_1) -[:connecte_a]-> (l)
Upvotes: 3