OrientDB如何匹配多个相关类

时间:2017-04-23 15:42:52

标签: orientdb orientdb2.2

我正在尝试编写一个MATCH语句来提取相关数据。

CREATE CLASS Member EXTENDS V;
CREATE CLASS DirectVolumes EXTENDS V;
CREATE SEQUENCE dvSequence TYPE ORDERED;
CREATE CLASS GroupVolumes EXTENDS V;
CREATE SEQUENCE groupVolumesSequence TYPE ORDERED;
CREATE CLASS GenerationVolumes EXTENDS V;
CREATE SEQUENCE genGroupVolumesSequence TYPE ORDERED;
CREATE SEQUENCE memberIdSeq TYPE ORDERED;
CREATE VERTEX Member SET id=sequence('memberIdSeq').next();
CREATE VERTEX DirectVolumes set id=sequence('dvSequence').next(); 
CREATE VERTEX GroupVolumes set id=sequence('groupVolumesSequence').next();
CREATE VERTEX GenerationVolumes set id=sequence('genGroupVolumesSequence').next();
CREATE EDGE OWNS_DV_CURRENT FROM (SELECT FROM Member WHERE id = 1) TO (select from DirectVolumes where id = 1);
CREATE EDGE OWNS_PG_CURRENT FROM (SELECT FROM Member WHERE id = 1) TO (select from GroupVolumes where id = 1); 
CREATE EDGE OWNS_GG_CURRENT FROM (SELECT FROM Member WHERE id = 1) TO (select from GenerationVolumes where id = 1); 

现在我想要会员,andOWNS_DV_CURRENT,OWNS_PG_CURRENT,OWNS_GG_CURRENT将数据边缘化。为简单起见,我删除了属性。 用MATCH做这个的正确方法是什么?我没有弄清楚如何获取多个相关的类。查询似乎没问题,但它返回0我认为它是在OWNS_DV_CURRENT之上寻找OWNS_PG_CURRENT而不是在会员本身。

select from (MATCH {class: Member, as:member}.out("OWNS_DV_CURRENT"){as:dv}.out("OWNS_PG_CURRENT") {as: pg} RETURN member, dv,pg)

1 个答案:

答案 0 :(得分:0)

试试这个:

 MATCH 
  {class: Member, as:member}.out("OWNS_DV_CURRENT"){as:dv},
  {as:member}.out("OWNS_PG_CURRENT") {as: pg} 
 RETURN member, dv,pg