如何使查询与OrientDB中的OR条件匹配

时间:2018-08-26 15:27:28

标签: orientdb

如何在OrientDB中编写具有OR条件的匹配项?

EG:我想查找用户具有accessTo的文件以及组用户所属的文件可以访问的文件。

select   from (
MATCH
{class: user, where:(userid='User1'), as: u},
{as:u}-accessTo->{class: so,where:(projectId='Project1'), as: r},
{as:u}-memberOf->{class: group, where:(projectId='Project1')}-accessTo-> 
{class: so,as: r}
RETURN r)

1 个答案:

答案 0 :(得分:0)

当前,MATCH语句中没有OR选项,因此您必须使用两个查询和一个unionAll:

select  unionAll($a, $b) 
LET
   $a = (MATCH
      {class: user, where:(userid='User1'), as: u},
      {as:u}-accessTo->{class: so,where:(projectId='Project1'), as: r},
   RETURN r),
   $b = (MATCH
      {class: user, where:(userid='User1'), as: u},
      {as:u}-memberOf->{class: group, where:(projectId='Project1')}-accessTo-> 
      {class: so,as: r}
   RETURN r),
)