Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A single relationship type must be specified for CREATE in Neo4j

Tags:

neo4j

I am trying to create a relationship between two nodes using using the below query:

load csv with headers from 
"file:C:/Users/abc/Documents/Neo4j/RT__RISK_LOSSEVENT.csv" as risklossevent 
match (a: RT__RISK_LOSSEVENT {LossEventId: risklossevent.LOSSEVENT_ID}),
(b: RT_RISK {RiskId: risklossevent.RISK_ID}) 
create (a)-[ASSOCIATED_WITH]->(b);

It is throwing the an error stating

A single relationship type must be specified for CREATE (line 1, column 236 (offset: 235))

Neo.ClientError.Statement.InvalidSyntax

For creating the two nodes, I have used the below queries:

load csv with headers from 
file:C:/Users/abc/Documents/Neo4j/RT__RISK_LOSSEVENT.csv" as risklossevent
create (rle1:RT__RISK_LOSSEVENT {RiskId: risklossevent.RISK_ID, LossEventId: risklossevent.LOSSEVENT_ID});

load csv with headers from "file:C:/Users/abc/Documents/Neo4j/RT_RISK.csv" as risk 
create (rle3:RT_RISK {RiskId: risk.RISK_ID, Owner: risk.OWNER, RiskCategory: risk.RISK_CATEGORY, Description: risk.DESCRIPTION});

Anyone knows what wrong with the syntax or the query?

like image 414
JGS Avatar asked Mar 02 '16 09:03

JGS


1 Answers

Indeed the exception you get is not really concerning the syntax error you have and thus not meaningful.

You forgot to add a colon : : before the relationship type in your query :

create (a)-[:ASSOCIATED_WITH]->(b);
like image 152
Christophe Willemsen Avatar answered Jan 04 '23 11:01

Christophe Willemsen