Reputation: 393
I had two set of nodes come under two different labels in neo4j(2V)
CREATE ( p1:pharma { name: "Magnesium", id: 12 } )
CREATE ( p2:pharma { name: "Hyoscine Butylbromide", id: 22 } )
CREATE ( p3:pharma { name: "Propantheline Bromide", id: 23 } );
CREATE ( i1:ind { id: 1, name: 'Dyspepsia', pdfk: '12'})
CREATE ( i2:ind { id: 5, name: 'Symptomic relief of intestinal disorder', pdfk: '22'})
CREATE ( i3:ind { id: 6, name: 'Symptomic relief of disorder', pdfk: '22'})
CREATE ( i4:ind { id: 7, name: 'Bowel colic', review: 'False', pdfk: '23'});
and my relationship code look like these for a single nodes from two set of labels
MATCH (a:pharma),(b:ind)
WHERE a.id = 12 AND b.id = 1
CREATE (a)-[:has_ind]->(b)
I want to know how can I write this as a batch query for other nodes too ? thanks in advance.
Iam using import.txt file with above code inside BEGIN COMMIT, then i use following code to create the database from command prompt
neo4jshell -path C:\progra~1\neo4j-community-2.0.0\data\drug11.db -config C:\progra~1\neo4j-community-2.0.0\conf\neo4j.properties -file C:\Users\admin\Downloads\import.txt
nodes will be created but not the relationship ?
Upvotes: 0
Views: 1409
Reputation: 399
Create ( p1:pharma { name: "Magnesium", id: 12 } )-[:has_ind]->( i1:ind { id: 1, name: 'Dyspepsia', pdfk: '12'})
should work I think?
Upvotes: 1
Reputation: 41676
You would issue one of your queries at a time (what is the API you use?)
MATCH (a:pharma {id:12}),(b:ind {id:1})
CREATE (a)-[:has_ind]->(b)
With Parameters would be faster:
MATCH (a:pharma {id:{pharma_id}}),(b:ind {id:{ind_id}})
CREATE (a)-[:has_ind]->(b)
and then use the params: {"pharma_id":12,"ind_id":1}
etc.
Upvotes: 0