【问题标题】:Gremlin: how to extract a value from selectGremlin:如何从选择中提取值
【发布时间】:2019-05-07 05:05:15
【问题描述】:

我有以下 gremlin 查询:

gremlin> g.E('96b546e0-bf87-9649-2694-ccc29acec83e').as('e')
    .properties('foo').as('foo').select('e').outV().outE()
    .has('foo', __.select('foo')).valueMap()

    ==>{foo=bar2}

    ==>{foo=bar}

上述查询旨在从一条边开始,然后从其 outV 中识别所有其他边,这些边具有相同的边属性 'foo' 值。问题是 has() 期望第二个参数有一个值,而 select() 返回一个属性

我的问题:。如何在起始边缘捕获 'foo' 的值,然后在 has() 或 where() 中使用该值来过滤掉与属性 'foo' 不共享相同值的边缘?

【问题讨论】:

    标签: gremlin


    【解决方案1】:

    要将一个元素的属性与另一个元素的属性进行比较,请使用where()

    g.E('96b546e0-bf87-9649-2694-ccc29acec83e').as('e').
      outV().outE().
      where(eq('e')).
        by('foo')
    

    要排除原始边缘,您可以:

    g.E('96b546e0-bf87-9649-2694-ccc29acec83e').as('e').
      outV().outE().
      where(neq('e')).
      where(eq('e')).
        by('foo')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      相关资源
      最近更新 更多