cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to Create the same name (or category) node in a load csv query

Peter_Lian
Node Clone

The following is my query

##################################

CALL apoc.periodic.iterate('

CALL apoc.load.json("Mydata") YIELD value return value','

UNWIND value.Event AS col_event

CREATE(process:Process{eventid: coalesce(col_event.System.EventID, "No ID"),

computer:coalesce(col_event.EventData.Computer,"No Computer"),

rulename:coalesce(col_event.EventData.Rulename,"No Rulename")})

CREATE(process:Process{eventid: coalesce(col_event.System.EventID, "No ID"),

euid:col_event.System.EventRecordID})',

{batchSize:10000, iterateList:true, parallel:true})

##################################

However, the error messages shows "Variable `process` already declared".

Question : How can I adjust the above result so that I can CREATE the above two types of node and all names and Process in just one query (CALL apoc.periodic.iterate)?

Remark : I know that I can query another CALL apoc.periodic.iterate to make it, however I want include all the query within a apoc.periodic.iterate command.

Thanks !

1 ACCEPTED SOLUTION

it seems odd to purposefully create two separate nodes when you know you are going to merge them. Why not create the equivalent of the merge node to start?

anyway, the binding variable doesn’t influence the type of node. It is just a reference to that node that can be used in the cypher query to refer to the node. You can safely remove the duplicate binding variables ‘process’ from both creates or change one to remove the duplication, and get the same query results for the query presented.

View solution in original post

5 REPLIES 5

Is your intent to create two nodes with the same eventId? If so, you can fix your code by changing the binding variable for the second create to something different than ‘process’. You can even remove the binding variable ‘process’ from both create clauses, since the codes does not reference either.

Yes, It's the different node with the same eventid. However, due to some private technique issue, I would merge this two node into one node based on eventid.

If I create two type node (for example, process and process2), then the apoc.refactor.mergeNodes can not work since they're not the same node but It work if the node are all named as "process". That's why I'm trying to create two type of node which all name process

it seems odd to purposefully create two separate nodes when you know you are going to merge them. Why not create the equivalent of the merge node to start?

anyway, the binding variable doesn’t influence the type of node. It is just a reference to that node that can be used in the cypher query to refer to the node. You can safely remove the duplicate binding variables ‘process’ from both creates or change one to remove the duplication, and get the same query results for the query presented.

Thanks, it was surprised that the binding variable (process:Proces) doesn’t influence the type of node. It shows the result successfully after modifying binding variable process to process2.

Yes, it does not influence the type of node.. It is just a variable to reference the node in your cypher query after it has been defined. The node’s label is what determines the nodes type.