Java driver run query does not return properties, just return the node with id

HI

String cql = "match (a:TestNode2) where id(a)=1241 
match (b:TestNode2) where id(b)=1240  
create (a)-[r:TESTRELATION]->(b)   return a, r, b "

Result result = driver.session().run(cql);

it only returns the node id and relation id, how can I get all the properties?
Thanks

        while (result.hasNext()) {
            Record record = result.next();
            Node aNode = record.get("a").asNode();
            Relationship rRel = record.get("r").asRelationship();
            Node bNode = record.get("b").asNode();
        }

Then, you can call .asMap() on any of the Node and Relationship and get access to every the property map.
Alternatively, you can call .get() to retrieve a single property, which is then returned as a Value instance. You then call asXxx on that value to get the expected type (asString, asBoolean, ...)

1 Like