[英]Neo4j Cypher match () in java. Find connected nodes
我有下面的結構
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通過關系“電子郵件”鏈接到第二和第三。 類似地,第二節點連接到第三,第四,第一。
我想為每個節點輸出類似這樣的內容:secondNode = [firstNode,FouthNode,ThirdNode],firstNode = [second,third],third = ...
我嘗試過這樣的事情:
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 "}
我對cypher很陌生。 如何為此編寫匹配語句? 這可能嗎?
嘗試這樣的事情:
MATCH (sender:Person)-[:EMAILS]->(receiver)
RETURN sender,collect(receiver) as receivers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.