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.

Can the property or relationship names be parameterized in creating the graph?

lingvisa
Graph Fellow

For example:

// Create orders
LOAD CSV WITH HEADERS FROM 'file:///orders.csv' AS row
MERGE (order:Order {orderID: row.OrderID})
  ON CREATE SET order.shipName = row.ShipName;

Can the 'order.shipName' be replaced with something like 'order.$shipName' where $shipname is a variable, which will be read from the csv file. The reason I want to do this is that, I want to create a function that can be reused for different data models. All the examples in the neo4j documentation use hard-coded statements like above to create the graph. In such a case, for a new data model, I have to write totally different scripts to build the graph. Ideally, I want to pass the csv headers as parameters to create the graph, so that the code can be reused.

Secondly, can even the 'order' (to be used as 'label') be parameterized in above code? Does APOC help achieve this purpose? This looks like a common requirement. Isn't it?

Thanks for help.

2 REPLIES 2

You can use APOC procedures to support dynamic labels

https://neo4j.com/docs/labs/apoc/current/graph-updates/data-creation/

Thanks. good to know