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.

Newbie need help inputting multiple relationships

Maybe someone can help me here. I am totally new to Neo4j. I have built a database with 3 different Nodes I now need to define the relationship between the data and like before I tested one relationship in the browser to ensure it works then moved over to Python to produce a dump file with commands to add the rest of the relationship data ( create (WR:WebSiteName{WebIP: '104.20.29.141'}) - [:WEBSITELOCATIONRELATION] ->(LR:Location{Ip: '104.20.29.141'}); ) Sample of my connection. Anyway when I dump the lines into the browser to run the create statements it I get an error (Neo.ClientError.Statement.SyntaxError: Expected exactly one statement per query but got: 1019) now I understand that it is looking for one statement at a time but is there away around this as I have a total of 1325 relationships to define?

I have run single statements and they do work.

Kind regards

Matthew Swart

4 REPLIES 4

12kunal34
Graph Fellow

Hi Matt,

Could you please share the data schema or Sample data for which you want to Create Relationship.
Bdw you can use below query structure for adding relationship

MATCH (WR:WebSiteName{WebIP: '104.20.29.141'})
MATCH (LR:Location{Ip: '104.20.29.141'}) 
CREATE (WR)-[:WEBSITELOCATIONRELATION]->(LR)

in above query if you want to avoid duplicate Relationshio then USE Merge instead of Create
one more thing as i can see in your query that is your location Ip and Website WebIP is same .

do you want to use constraint that Website WebIP = location Ip ??

If you want to use this Constraint then Query can be like below

Match(WR:WebSiteName)
Match (LR:Location) WITH WR,LR WHERE WR.WebIP= LR.Ip
merge(WR)-[r:Having]->(LR)

Data summary:
107 of ---> CREATE (W0:WebSiteName { webIP: "104.24.19.110" ,webName: "www.agriland.ie"}); (Obviously each one is different website and ip.

995 of ----> CREATE (H0:HopInfo { webIPForHop: "104.24.19.110" ,HopNumber: "1" ,HopIP: "192.168.43.1" ,RTT1: "12.221" ,RTT2: "12.198" ,RTT3: "12.177"});

1917 of ----> CREATE (L0:Location { lon: "-122.348" ,lat: "47.6339" ,Ip: "52.93.101.61" });

Then I need to make connections/relationships:
147 of -----> create (WR:WebSiteName{WebIP: '104.123.112.198'}) - [:WEBSITELOCATIONRELATION] -> (LR:Location{Ip: '104.123.112.198'});

1176 of ----> create (HR:HopInfo{HopIP: '129.250.6.18'}) - [:HOPLOCATIONRELATION] -> (LHR:Location{Ip: '129.250.6.18'});

Thanks for the suggestion on the add relationships I am rebuilding dump file now.

The top 3 create statements have gone in to the database with no trouble at all.
It is just the relationship data that is giving me issues, But I can input those statements one at a time.

As you can see if I try run two of the revised statements it says it was expecting one but got 2 and I am wondering is there a way to overcome this.


Running one revised query works perfectly fine.

OK figured out the issue on the desktop I needed to go into settings and tick the "Enable multi statement query editor" box.

12kunal34
Graph Fellow

so is it working fine now ??
or is there any issue ?