【问题标题】:How to get the available connected vertex in OrientDB如何在 OrientDB 中获取可用的连接顶点
【发布时间】:2018-01-25 10:06:51
【问题描述】:

我有一个案例:我想从一个基础顶点获取所有连接的顶点(包括中间顶点)。

例如下图 enter image description here

我想从顶点(“giggs”)查询所有连接的顶点,我也想查询连接的路径。例如:“吉格斯”->“192.168.0.1”->“罗纳尔多”->“192.168.0.2”->“veri”。我使用如下查询:

MATCH {class: ic, as: s, where: (title = 'giggs')}.(outE(){where: 'some condition'}.inV().inE(){where: 'some condition'}.outV()){class: %s, as: t, while: ($depth <= 5), where: ($matched.s != $currentMatch)} RETURN $paths

我可以得到所有的目标节点,例如:“veri”,但我不知道“veri”的前一个顶点以及“veri”与其前一个顶点之间的边。

那么我该如何编写查询呢?提前致谢。

【问题讨论】:

    标签: orientdb


    【解决方案1】:

    试试这个:

    TRAVERSE both() FROM (SELECT EXPAND(s) FROM (MATCH {CLASS:ic, AS:s, WHERE:(name='giggs')} RETURN s))
    

    希望对你有帮助

    问候

    【讨论】:

    • 谢谢博尼兹。如果我使用遍历,如何在边缘添加搜索条件?因为我需要添加约束,因为部分边缘符合我的查询条件。我浏览了官方文档(orientdb.com/docs/last/SQL-Traverse.html),看来我只能在顶点上添加条件。但如果我错了,请告诉我。
    • 你能举个例子吗?谢谢
    • 例如:MATCH {class: ic, as: s, where: (title = 'giggs')}.(outE(){where: 'occur_time between date('2018-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss') 和日期('2018-01-27 00:00:00', 'yyyy-MM-dd HH:mm:ss')' }.inV().inE(){where: 'occur_time between date('2018-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss') 和 date('2018-01 -27 00:00:00', 'yyyy-MM-dd HH:mm:ss')'}.outV()){class: %s, as: t), 其中: ($matched.s != $ currentMatch)} RETURN $paths,它的边缘条件如 'occur_time between date('2018-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss') 和 date('2018- 01-27 00:00:00', 'yyyy-MM-dd HH:mm:ss')'。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多