如何获得连接 Orient db 中两个特定顶点的边

How can I get the edges that connect two specific vertices in Orient db

我已尝试使用文档和控制台,但没有找到执行此操作的方法。

带有 属性 "A" 的顶点,带有 属性 "B" 的顶点和带有标签 "Connected".

的边

我想找出连接这两个顶点的边并获取边的 id

我没能做到这一点。我可以

select from (SELECT EXPAND(BOTH('Connected')) FROM Tag WHERE prop='A') where prop='B'

但我需要获得优势@rid。如果我将 BOTH 更改为 BOTHE 那么我如何专门要求带有 prop B.

的标签

我也试过:

SELECT FROM Connected WHERE IN=(SELECT FROM TAG WHERE prop = 'A') AND OUT = (SELECT FROM TAG WHERE prop = 'B')

但我没有从中得到任何东西

更新:

select from Connected where (out in (select from Tag where tagName='testTagA') AND in in (select from Tag where tagName='testTagB')) OR (out in (select from Tag where tagName='testTagB') AND in in (select from Tag where tagName='testTagA'))

这个问题解决了,但是有没有更直接的方法呢?我认为这会扫描具有给定标签的所有边缘。

试试这个查询

select from Connected where out in (select from Tag WHERE prop = 'B' ) and in in (select from Tag WHERE prop = 'A' )

试试这个:

1:

SELECT FROM (
    SELECT EXPAND(BOTHE('Connected')) FROM Tag WHERE prop='A'
) WHERE in.prop='B' or out.prop='B'

2:

SELECT FROM Connected 
WHERE (in.prop = 'A' AND out.prop = 'B') OR (in.prop = 'B' AND out.prop = 'A')

2b:

SELECT FROM Connected 
LET $inProp = in.prop, $outProp = outProp = out.prop 
WHERE ($inProp = 'A' AND $outProp = 'B') OR ($inProp = 'B' AND $outProp = 'A')

我不确定你哪个最快,你必须尝试一下,因为它取决于你的数据库和查询的其他部分。 2b 比 2 快,但差距很小。