OrientDB的图遍历

网上大部分orientDB的查询方案都是sql的,但是多表联查(sql)会比较麻烦。貌似orientDB不支持cypher(neo4j 支持),查询了官网似乎没有match,所以找到下面查询方案

 

 简单 顶点-边-顶点

MATCH
    {as:term,class:term_zh,where:(name='进行')}.outE("intimacy"){as:cc,class:intimacy}.inV("term_zh"){as:dd,class:term_zh} 
RETURN  term,cc.value,dd.name,dd.@rid
 

 简单 顶点-边-顶点-边-顶点(查询和某个顶点有亲密度的顶点的 所有指向顶点)

MATCH
    {as:term,class:term_zh,where:(name='减值')}.outE(){as:cc,class:intimacy}.inV(){as:dd,class:term_zh}.inE(){as:ee,class:include}.outV(){as:gg,class:v}
RETURN  term,cc.value,dd.name,dd.@rid,ee.out,gg,gg.title,gg.name
 

 查询某些没有值的节点 且分页

select * from(
MATCH {as:term,class:term_zh}.outE(){as:intimacy,class:intimacy,optional:true}.inV(){as:aa,class:v,optional:true}
return term.@rid as row,term.name,intimacy.value,aa.name
) where row in (select @rid from term_zh limit 10)

 

// 查询V通过E相关联的V,三个深度层级,且显示关联E
 TRAVERSE inE("intimacy"),in("intimacy") FROM (select @rid from term_zh skip 0 limit 10)    MAXDEPTH 3 WHILE  @class='term_zh' or @class='intimacy'
// 查询V通过E相关联的V,三个深度层级
 TRAVERSE in("intimacy") FROM (select @rid from term_zh skip 0 limit 10)    MAXDEPTH 3 WHILE  @class='term_zh' 

 

参考文档 https://cloud.tencent.com/developer/article/1528023

posted @ 2021-02-01 10:04  zhyue  阅读(210)  评论(0编辑  收藏  举报