【问题标题】:Gremlin: how to find other edges with the same propertyGremlin:如何找到具有相同属性的其他边
【发布时间】:2019-03-14 18:12:28
【问题描述】:

我有一个图,其中两个顶点的 id(s) 为“a”和“b”。

小鬼> g.V()

==>v[b]

==>v[a]

从“a”到“b”有两条边。

gremlin> g.E()

==>e[a6b4bead-c161-5a61-d232-abfa2bfad54e][a-LIKES->b]

==>e[10b4bead-a0fc-8d2c-d69f-26b3e9e4c5d8][a-KNOWS->b]

gremlin> g.E().valueMap(true)

==>{id=a6b4bead-c161-5a61-d232-abfa2bfad54e, semantics=social, label=LIKES}

==>{id=10b4bead-a0fc-8d2c-d69f-26b3e9e4c5d8, semantics=social, label=KNOWS}

我的问题:给定一个边的 id,我想为属性“语义”找到具有相同值的所有其他边。例如,给定 a.LIKES.id,我想执行一个查询,该查询将使用值 a.LIKES.semantics 返回 a.KNOWS。

我开始:

g.E('a6b4bead-c161-5a61-d232-abfa2bfad54e') .property('semantics').as('semantics')...这就是我卡住的地方

谢谢, 乔尔

【问题讨论】:

  • 您想考虑图中的所有边还是只考虑与a(和/或b)相关的边?
  • 只有那些事件发生在'a'

标签: gremlin


【解决方案1】:

where()by() 调制器一起完成这项工作:

g.E('a6b4bead-c161-5a61-d232-abfa2bfad54e').as('e').
  outV().inE().
  where(eq('e')).by('semantics'). // return edges with the same semantics property value
  where(neq('e'))                 // ... except the one we started with

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 2012-03-12
    • 1970-01-01
    • 2019-05-29
    相关资源
    最近更新 更多