1

使用 RedisGraph,我想要一个查询来返回一个关系的类型。

一个示例查询:

MATCH (n1:Entity { id: "foo" }) MATCH (n2:Entity2 { id: "bar" }) CREATE (n1)-[r:areFriends]->(n2) RETURN *

不幸的是,返回值只包括n1and n2,但不包括r

返回的记录包含以下内容:

Record { _header: [ 'n1.id', 'n1.name', 'n2.id', 'n2.name' ] 这符合我的架构,但r在那里却是出了名的缺失。

如何让 RETURN 返回关系?

OpenCypher 支持如下语法:

RETURN n1, n2, type(r)但这似乎在 RedisGraph 中不起作用。

4

2 回答 2

1

目前 RedisGraph 不支持混合 CREATE 和 RETURN 子句,尽管这项工作正在制作中并且应该在几天内可用。

于 2019-01-17T18:41:40.573 回答
1

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

于 2019-01-20T07:03:31.130 回答