Neo4j Cypher: How to iterate over ExecutionResult result

前端 未结 4 1489
深忆病人
深忆病人 2020-12-16 22:02

In this code, how could I iterate over all the nodes in the ExecutionResult result?

CypherParser parser = new CypherParser();
ExecutionEngine engine = new Ex         


        
4条回答
  •  无人及你
    2020-12-16 22:35

    In newer versions of the java driver one can traverse like this.

    Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "neo4j"));
    Session session = driver.session();
    List teams = new ArrayList<>();
    
    StatementResult cursor = session.run("match (l:League)<-[]-(t:Team) return t.short_name");
    while (cursor.hasNext()) {
        teams.add(cursor.next().get(cursor.keys().get(0)).toString());
    }
    
    session.close();
    driver.close();
    

提交回复
热议问题