【问题标题】:Gremlin - How to filter edges on property when getting shortest pathGremlin - 如何在获得最短路径时过滤属性边缘
【发布时间】:2019-10-10 14:55:52
【问题描述】:

以下查询搜索从给定顶点 (377524408) 到具有属性 test_property 的边的另一个顶点的最短路径集,并在 3 次迭代后退出(即,如果在 3 次遍历中没有找到顶点,我们不返回任何路径)。

s.V(377524408).repeat(both().simplePath())
    .until(or(__.bothE().has('test_feature', gt(0)), 
              loops().is(lt(4))))
    .path().dedup().toList()

但是,我想过滤上述查询遍历的边。

例如,仅遍历具有属性filter_property

【问题讨论】:

    标签: gremlin janusgraph gremlin-server gremlinpython


    【解决方案1】:

    您可以使用bothE().has('filter_property', lt(100)).otherV(),而不是both().simplePath()

    另外,请注意,loops().is(lt(4)) 将始终在第一次迭代中评估 true。你可能希望它是loops().is(3)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      • 2022-08-08
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多