I am trying to auto generate a a text file that can be run to create the nodes and relationships for a Neoj4 Graph.
The text file is being created in two sections:
First the nodes are created in a For loop (6000 nodes) with a result like this:
create(SystemLogic_d6:FB {type:"SUB_DINT", instanceName:"d6", section:"SystemLogic"})
create(SystemLogic_d5:FB {type:"SUB_DINT", instanceName:"d5", section:"SystemLogic"})
create(SystemLogic_d7:FB {type:"ADD_DINT", instanceName:"d7", section:"SystemLogic"})
create(SystemLogic_d8:FB {type:"SEL", instanceName:"d8", section:"SystemLogic"})
Then in the next section of the text file relationships are created in another For loop wih a result like this:
MATCH (SystemLogic_d8:FB), (SystemLogic_d12:FB) WHERE SystemLogic_d8.instanceName = "d8" AND SystemLogic_d12.instanceName = "d12" CREATE (SystemLogic_d8)-[: c]->(SystemLogic_d12)
MATCH (SystemLogic_d17:FB), (SystemLogic_d18:FB) WHERE SystemLogic_d17.instanceName = "d17" AND SystemLogic_d18.instanceName = "d18" CREATE (SystemLogic_d17)-[: c]->(SystemLogic_d18)
MATCH (SystemLogic_d16:FB), (SystemLogic_d17:FB) WHERE SystemLogic_d16.instanceName = "d16" AND SystemLogic_d17.instanceName = "d17" CREATE (SystemLogic_d16)-[: c]->(SystemLogic_d17)
MATCH (SystemLogic_d11:FB), (SystemLogic_d5:FB) WHERE SystemLogic_d11.instanceName = "d11" AND SystemLogic_d5.instanceName = "d5" CREATE (SystemLogic_d11)-[: c]->(SystemLogic_d5)
This is giving the error WITH is required between CREATE and MATCH
I tried inserting a WITH in between as in this answer
Neo4j Cypher WITH is required between CREATE and MATCH:
Which gives a result like this:
MATCH (SystemLogic_d8:FB), (SystemLogic_d12:FB) WITH SystemLogic_d8,SystemLogic_d12 WHERE SystemLogic_d8.instanceName = "d8" AND SystemLogic_d12.instanceName = "d12" CREATE (SystemLogic_d8)-[: c]->(SystemLogic_d12)
MATCH (SystemLogic_d17:FB), (SystemLogic_d18:FB) WITH SystemLogic_d17,SystemLogic_d18 WHERE SystemLogic_d17.instanceName = "d17" AND SystemLogic_d18.instanceName = "d18" CREATE (SystemLogic_d17)-[: c]->(SystemLogic_d18)
MATCH (SystemLogic_d16:FB), (SystemLogic_d17:FB) WITH SystemLogic_d16,SystemLogic_d17 WHERE SystemLogic_d16.instanceName = "d16" AND SystemLogic_d17.instanceName = "d17" CREATE (SystemLogic_d16)-[: c]->(SystemLogic_d17)
MATCH (SystemLogic_d11:FB), (SystemLogic_d5:FB) WITH SystemLogic_d11,SystemLogic_d5 WHERE SystemLogic_d11.instanceName = "d11" AND SystemLogic_d5.instanceName = "d5" CREATE (SystemLogic_d11)-[: c]->(SystemLogic_d5)
MATCH (SystemLogic_FBI_1407:FB), (SystemLogic_FBI_1408:FB) WITH SystemLogic_FBI_1407,SystemLogic_FBI_1408 WHERE SystemLogic_FBI_1407.instanceName = "FBI_1407" AND SystemLogic_FBI_1408.instanceName = "FBI_1408" CREATE (SystemLogic_FBI_1407)-[: c]->(SystemLogic_FBI_1408)
But I still get the same error
I also tried putting the WITH statement after the create statement but that gives another error.
Are you able to import and run multiple node/relationships creation statements in this fashion?
It works fine for creating the nodes but I am new to using Neo4J / Cypher and I am not sure if it is my syntax that is incorrect or that you can't create multiple relatiionships in this fasion.
Thanks for your help