sathya
sathya

Reputation: 553

How to use neo4j rest api to post multiple nodes and their relationships through a single request?

I'm new to neo4j. I want to use the neo4j rest api to post a stream of edges of a graph (more than million nodes and their relationships) to neo4j.

I'm reading the edges from a dataset and using a jersey client to post the edges to neo4j. What i understood from the REST api documentation is that to create an edge, i have to create two nodes by sending a post request to the /node uri and then obtain the id of the created node from the response and send the relationship (edge) to the node/id/relationships uri after that. Is that the correct way to do that? How do i post multiple nodes and their relationships through a single request?

Upvotes: 1

Views: 399

Answers (1)

undefined
undefined

Reputation: 34238

With cypher you would do something like this:

MATCH (n:NodeType {some:'condition'})
MATCH (o:OtherNodeType {another:'condition'})
CREATE (n) - [:EdgeType] -> (o)

This finds two nodes n and o and then creates a relationship (edge) between.

I havent personally used the rest client direcly but there will be a call to pass a cypher query.

Upvotes: 0

Related Questions