How to return relationship type with Neo4J's Cypher queries? -
i trying relationship type of simple cypher query, following
match (n)-[r]-(m) return n, r, m;
unfortunately return empty object r
. troublesome since can't distinguish between different types of relationships. can monkey patch adding property [r:knows {type:'knows'}]
wondering if there isn't direct way relationship type.
i followed official neo4j tutorial (as described below), demonstrating problem.
graph setup:
create (_0 {`age`:55, `happy`:"yes!", `name`:"a"}) create (_1 {`name`:"b"}) create _0-[:`knows`]->_1 create _0-[:`blocks`]->_1
query:
match p=(a { name: "a" })-[r]->(b) return *
json response body:
{ "results": [ { "columns": [ "a", "b", "p", "r" ], "data": [ { "row": [ { "name": "a", "age": 55, "happy": "yes!" }, { "name": "b" }, [ { "name": "a", "age": 55, "happy": "yes!" }, {}, { "name": "b" } ], {} ] }, { "row": [ { "name": "a", "age": 55, "happy": "yes!" }, { "name": "b" }, [ { "name": "a", "age": 55, "happy": "yes!" }, {}, { "name": "b" } ], {} ] } ] } ], "errors": [] }
as can see, empty object r
, makes impossible distinguish between relationships.
note: running neo4j v.2.2.2
use type()
function.
match (n)-[r]-(m) return type(r);
Comments
Post a Comment