Using RedisGraph, I'd like for a QUERY to RETURN a relation's type.
An example query:
MATCH (n1:Entity { id: "foo" }) MATCH (n2:Entity2 { id: "bar" }) CREATE (n1)-[r:areFriends]->(n2) RETURN *
Unfortunately, the returned value only includes n1
and n2
, but not r
.
The returned record contains the following:
Record {
_header: [ 'n1.id', 'n1.name', 'n2.id', 'n2.name' ]
This is compliant with my schema, yet r
is notoriously missing there.
How can I get RETURN to return the relation?
OpenCypher supports syntax like:
RETURN n1, n2, type(r)
but this doesn't seem to work in RedisGraph.
PR just merged to MASTER
127.0.0.1:6379> GRAPH.QUERY G "create (:Entity {id:'foo'}), (:Entity {id:'bar'})"
1) (empty list or set)
2) 1) "Labels added: 1"
2) "Nodes created: 2"
3) "Properties set: 2"
4) "Query internal execution time: 0.536000 milliseconds"
127.0.0.1:6379> GRAPH.QUERY G "MATCH (n1:Entity {id:'foo'}), (n2:Entity {id:'bar'}) CREATE (n1)-[r:areFriends]->(n2) RETURN n1,n2,TYPE(r)"
1) 1) 1) "n1.id"
2) "n2.id"
3) "TYPE(r)"
2) 1) "foo"
2) "bar"
3) "areFriends"
2) 1) "Relationships created: 1"
2) "Query internal execution time: 0.409000 milliseconds"
Please note, this change will be part of version 1.0.12
Until that version is released, you can either build from source or use docker image redislabs/redisgraph:edge