OrientDB从多个边缘选择唯一的顶点

时间:2016-05-21 19:57:49

标签: orientdb graph-databases

我有2个顶点User和Stamp。顶点与三个边缘相关,有,WishToHave和Selling。

我希望选择与用户有任何关系的独特邮票。要做到这一点,我正在运行此命令:

select expand(out('Have', 'WishToHave', 'Selling')) from #12:0

此命令的问题在于它返回' Stamp1'几次,因为它有卖出边缘。

如何选择与User1相关的所有唯一/不同邮票?

为此示例初始化测试数据:

create class User extends V
create class Stamp extends V

create class Have extends E
create class WishToHave extends E
create class Selling extends E

create vertex User set name = 'User1'
create vertex Stamp set name = 'Stamp1'
create vertex Stamp set name = 'Stamp2'
create vertex Stamp set name = 'Stamp3'


create edge Have from (select from User where name = 'User1') to (select from Stamp where name = 'Stamp1')
create edge WishToHave from (select from User where name = 'User1') to (select from Stamp where name = 'Stamp2')
create edge Selling from (select from User where name = 'User1') to (select from Stamp where name = 'Stamp1')
create edge Selling from (select from User where name = 'User1') to (select from Stamp where name = 'Stamp3')

1 个答案:

答案 0 :(得分:0)

我尝试了你的结构:

enter image description here

要检索唯一顶点,您可以使用 <Image.Source> <OnPlatform x:TypeArguments="ImageSource"> <OnPlatform.iOS><FileImageSource File="header.png"/></OnPlatform.iOS> <OnPlatform.Android><FileImageSource File="header.png"/></OnPlatform.Android> <OnPlatform.WinPhone><FileImageSource File="Assets/header.png"/></OnPlatform.WinPhone> </OnPlatform> </Image.Source> 函数。我可以举两个例子:

查询1:在目标查询中使用DISTINCT()

EXPAND()

<强>输出:

enter image description here

查询2:在目标查询中使用SELECT EXPAND(DISTINCT(@rid)) FROM (SELECT EXPAND(out('Have', 'WishToHave', 'Selling')) FROM #12:0)

UNWIND

<强>输出:

{{3}}

希望有所帮助