Mokshed Kaushik
Mokshed Kaushik

Reputation: 11

get all graph data including nodes and relationships from neo4j using java into a hashmap

I am trying to get all graph data including nodes and relationships from neo4j using java into a Hashmap to be able to read all nodes and their data for further manipulation with the data. I have tried using this query but it returns an error.

try (Session session = driver.session()) { 
    return session.run("MATCH (m) RETURN m");
}

I am trying to figure out how can I get the data in the right format.

Upvotes: 0

Views: 248

Answers (1)

jose_bacoy
jose_bacoy

Reputation: 12684

You can use below example to parse the result from neo4j query. If you get into any issue(s), pls let me know. Thanks.

Iterator<Node> javaNodes = execResult.columnAs("m");
for (Node node : IteratorUtil.asIterable(javaNodes))
{
    //parse the node in here
}

Reference: https://neo4j.com/docs/java-reference/current/java-embedded/cypher-java/

Upvotes: 1

Related Questions