我有follwing結構Neo4j Cypher match()in java。查找連接節點
firstNode = graphDb.createNode();
firstNode.setProperty("person", "Andy ");
Label myLabel = DynamicLabel.label("A");
firstNode.addLabel(myLabel);
secondNode = graphDb.createNode();
secondNode.setProperty("person", "Bobby");
Label myLabel1 = DynamicLabel.label("B");
secondNode.addLabel(myLabel1);
ThirdNode = graphDb.createNode();
ThirdNode.setProperty("person", "Chris ");
Label myLabel2 = DynamicLabel.label("C");
ThirdNode.addLabel(myLabel2);....
relationship = firstNode.createRelationshipTo(secondNode, RelTypes.emails);
relationship.setProperty("relationship", "email ");
relationship = firstNode.createRelationshipTo(ThirdNode, RelTypes.emails);
relationship.setProperty("relationship", "email ");
relationship = secondNode.createRelationshipTo(ThirdNode, RelTypes.emails);
relationship.setProperty("relationship", "email ");
relationship = secondNode.createRelationshipTo(FourthNode, RelTypes.emails);
relationship.setProperty("relationship", "email ");
firstNode被鏈接到第二和第三的關係「電子郵件」。同樣,第二個節點連接到第三,第四,第一個。
我要爲每個節點輸出somethinglike此:secondNode = [firstNode,FouthNode,ThirdNode],firstNode = [第二,第三],第三= ...
我嘗試是這樣的:
try{
ExecutionEngine engine = new ExecutionEngine(graphDb);
ExecutionResult result = engine.execute("MATCH (secondNode{person:'Bobby'})<-[:emails]-(node)RETURN node");
System.out.println(result.dumpToString());
tx1.success();
}
我得到了輸出:Node[0]{person:"Andy "}
我對密碼很陌生。如何爲此編寫匹配語句?這可能嗎?
不要創建一個新的執行引擎使用graphDb.execute! –