Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中的Neo4j-Cypher-match()。查找连接的节点_Java_Neo4j_Cypher - Fatal编程技术网

java中的Neo4j-Cypher-match()。查找连接的节点

java中的Neo4j-Cypher-match()。查找连接的节点,java,neo4j,cypher,Java,Neo4j,Cypher,我有如下结构 firstNode = graphDb.createNode(); firstNode.setProperty( "person", "Andy " ); Label myLabel = DynamicLabel.label("A"); firstNode.addLabel(myLabel); secondNode = graphDb.createNode(); secondNode.

我有如下结构

        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 " );
第一个节点通过关系“emails”链接到第二个和第三个节点。类似地,第二节点连接到第三、第四、第一节点

我希望每个节点的输出如下: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();
    } 
MATCH (sender:Person)-[:EMAILS]->(receiver) 
RETURN sender,collect(receiver) as receivers
试试看{
ExecutionEngine=新的ExecutionEngine(graphDb);
ExecutionResult=engine.execute(“匹配(第二个节点{person:'Bobby'))
  • 你的标签应该是:Person而不是:A,:B,:C
  • 您希望按第一个节点进行聚合
  • 您应该使用大写的re-types
试着这样做:

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();
    } 
MATCH (sender:Person)-[:EMAILS]->(receiver) 
RETURN sender,collect(receiver) as receivers

不要创建新的执行引擎使用graphDb.execute!!谢谢。太好了!它工作了。但是我没有指定方向。我已经提出了一个基于此的后续问题。你能检查一下吗?