简体   繁体   English

使用 java 从 neo4j 获取所有图形数据,包括节点和关系到 hashmap

[英]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.我正在尝试使用 java 从 neo4j 获取所有图形数据,包括节点和关系到 Hashmap 中,以便能够读取所有节点及其数据以进一步处理数据。 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.我试图弄清楚如何以正确的格式获取数据。

You can use below example to parse the result from neo4j query.您可以使用以下示例解析 neo4j 查询的结果。 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/参考: https://neo4j.com/docs/java-reference/current/java-embedded/cypher-java/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM