如何用java在Neo4j中编写查询

时间:2014-03-14 16:11:56

标签: networking neo4j cypher friend

我的数据结构是:

Node node1 = graphDb.createNode();
node1.setProperty("id", "123");
Node node2 = graphDb.createNode();
node1.setProperty("id", "456");
Node node3 = graphDb.createNode();
node1.setProperty("id", "789");
node1.createRelationshipTo(node2, RelTypes.HASFOLLOW);
node1.createRelationshipTo(node3, RelTypes.HASFOLLOW);
node2.createRelationshipTo(node3, RelTypes.HASFOLLOW);

我想查询node1的关注者(node2,node3)并查询谁跟随node3(node1,node2)。 final ExecutionEngine engine = new ExecutionEngine(graphDb); ExecutionResult result = engine.execute("START n=node(*) RETURN n.id"); 如何编写上面的代码?

1 个答案:

答案 0 :(得分:2)

很抱歉,这是一款经典的RTFM,请参阅http://docs.neo4j.org/chunked/stable/query-create.html