Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-04-2021 02:15 AM
I want to create a set of edges using LOAD CSV. I want their labels to be parameters from the file. I naively tried this:
LOAD CSV WITH HEADERS FROM "file:///edges.csv" AS row
MATCH(node1:row.tag1 {name:row.name1}),(node2:row.tag2 {name:row.name2}) CREATE (node1)-[:edge {carries:row.carries}]->(node2);
This is the error I get:
# ERROR Neo.ClientError.Statement.SyntaxError
# Invalid input '.': expected "$", ")" or "{" (line 2, column 16 (offset: 70))
# "MATCH(node1:row.tag1 {name:row.name1}),(node2:row.tag2 {name:row.name2}) CREATE (node1)-[:edge {carries:row.carries}]->(node2);"
# ^
Can someone suggest a way to label edges using LOAD CSV? Thanks!
10-04-2021 05:18 AM
Per Parameters - Neo4j Cypher Manual
Parameters cannot be used for the following constructs, as these form part of
the query structure that is compiled into a query plan:
* property keys; so, MATCH (n) WHERE n.$param = 'something' is invalid
* relationship types
* labels
so the failure you encounter is expected. And also to allow for parameters to be used for labels would prove challenging from a query planner perspective. If row1 of the csv had a row.tag1
of :Person
and this label had 4 indexes on properties, a,b,c,d but row 2 of the csv had a row.tag1
of :Movie
and this label had 2 indexes on properties x and y I'm not sure how the planner would ever figure out how to plan.
10-04-2021 08:00 AM
Thank you. Is there a suggested or commonly accepted work around?
All the sessions of the conference are now available online