首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tinkerpop3 gremlin的交集查询

tinkerpop3 gremlin的交集查询
EN

Stack Overflow用户
提问于 2017-01-20 19:39:26
回答 1查看 487关注 0票数 2

我正在使用DSE-5.0.5和DSE-studio,并且想在notebook graph中用gremlin编写一个查询。有没有一个交集查询可以给出在tinkerpop3中通过遍历返回的两个集合之间的公共元素。

我写了这个查询:

g.V().has('name',g.V'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的交集。或者,有没有一种有效的方式来写这篇文章,可以让我做到这一点?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-21 01:41:12

如果有一个样例图会很有帮助,但我认为这应该可以工作:

代码语言:javascript
复制
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"))
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41762817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档