OrientDb中顶点存在/不存在出线边 [英] Presence / absence of an outgoing edge from a vertex in OrientDb

查看:231
本文介绍了OrientDb中顶点存在/不存在出线边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SO上也看到过类似的问题,但是没有一个答案对我有用,因此我希望获得新的答案,因为已经提出了OrientDb的最新版本中增加的新功能,因为提出了其他问题

I have seen some similar questions on SO but none of the answers have worked for me yet, so I am hoping to get a new answer with the new features that have been added to recent versions of OrientDb since the other questions were asked.

我正在尝试查询所有具有特定类型输出边缘但没有其他类型输出边缘的顶点.

I am trying to query all vertices which have an outgoing edge of a particular type but no outgoing edge of another type.

人----朋友--->人

Person ---- Friend ---> Person

人----拥有--->汽车

Person ---- Owns ---> Car

我正在寻找所有有朋友但不拥有汽车的人.

I am trying to find all the persons who have friends but do not own a car.

我已经尝试了以下查询,但是没有运气(它返回所有人员,而不管这些顶点是否具有特定种类的出射边缘)

I have already tried the following query with no luck (It returns all the persons irrespective of whether or not those vertices have an outgoing edge of a particular kind)

select from Person where (out('Friend') not null and out('Owns').size() = 0)
select from Person where (out('Friend') is not null and out('Owns') is null)

在我的努力下,按照以下页面,我意识到OrientDb在WHERE子句中尚不支持NOT查询: https://github.com/orientechnologies/orientdb/wiki/SQL-Where 有人可以验证这是否是真的.

In my efforts I realized that the NOT query is not supported yet by OrientDb in the WHERE clause as per this page: https://github.com/orientechnologies/orientdb/wiki/SQL-Where Can someone please verify if this is indeed true.

无论如何,我继续前进并尝试简化查询,并尝试仅查找没有"Owns"输出边缘的顶点.即使那样也行不通,因为它似乎返回了我图中的所有Person顶点:

Anyways, I moved on and tried to simplify my query and tried to find only vertices that do not have the outgoing edge of 'Owns'. Even that did not work in that it seemed to return all the Person vertices in my graph:

select from Person where (out('Owns').size() = 0)
select from Person where (out('Owns') is null)

不确定我缺少什么,但是一如既往地感谢您的帮助.

Not sure what I am missing, but any help is as always greatly appreciated.

推荐答案

尝试始终使用尺寸,例如:

Try working always with size, like this:

select from Person where outE('Friend').size() > 0 and outE('Owns').size() = 0

这篇关于OrientDb中顶点存在/不存在出线边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆