【问题标题】:Intersect query for tinkerpop3 gremlintinkerpop3 gremlin 的相交查询
【发布时间】:2017-01-20 11:39:26
【问题描述】:

我正在使用 DSE-5.0.5 和 DSE-studio 并想在笔记本图形内的 gremlin 中编写查询。 是否有一个相交查询可以给我通过 tinkerpop3 中的遍历返回的两个集合之间的共同元素。

我已经写了这个查询:

g.V().has('name','Person1').outE('BELONGS').inV().inE('HAS').outV().as('x').inE(' HAS').outV().as('y').inE('HAS').outV().has('name','App1').select('x').inE('HAS') .outV().hasLabel('Org').as('p').repeat(out()).until(outE().hasLabel('IS')).as('a1').select(' y').inE('HAS').outV().hasLabel('Class').repeat(inE('IS').dedup().otherV()).until(inE().hasLabel('HAS ')).as('a2').select('a1','a2')

所以我想要集合 a1 和 a2 的交集。 或者有没有一种有效的方式来写这个可以给我那个?

【问题讨论】:

    标签: datastax-enterprise gremlin tinkerpop tinkerpop3 datastax-enterprise-graph


    【解决方案1】:

    如果有一个示例图表会很有帮助,但我认为这应该可行:

    g.V().has("name","Person1").
      out("BELONGS").in("HAS").dedup().as("x").
      in("HAS").filter(__.in("HAS").has("name","App1")).store("y").
      select("x").dedup().in("HAS").hasLabel("Org").
      repeat(out()).until(outE().hasLabel("IS")).store("a").cap("y").
      unfold().in("HAS").hasLabel("Class").
      repeat(inE("IS").dedup().otherV()).until(inE("HAS")).
      where(within("a"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      相关资源
      最近更新 更多