Tinkerpop Gremlin 查询:查找当前路径中指向回顶点的所有边

问题描述 投票:0回答:1

我查询以下路径:

Company
Employees
User

User
我想找到所有指向
当前
HasRights
Company
边(用户还拥有其他公司的权利)。

请参阅下面代码中的 TODO:

小鬼查询:


g.V()
.hasLabel("Company")
.project("Company","Employees")
// >>>> this is the company I want to filter by below
  .by(__.identity())
  .by(__.out("Has").hasLabel("Employee").not(__.has("IsDeleted",true)).has("Status",neq(5).and(neq(4)))
  .project("Employee","User","Rights")
    .by(__.identity())
    .by(__.out("Has").hasLabel("User"))
    .by(__.out("Has").hasLabel("User").outE("HasRight")
// >>>> TODO here I need to filter by above company
      .where(__.inV().hasLabel("Company")))
  .fold())
.fold())
gremlin tinkerpop gremlinnet
1个回答
0
投票

稍微简化一下,只是为了使示例更小,在这种情况下,您应该能够使用此模式:

g.V().hasLabel('Company').as('c').
      out('Has').hasLabel('Employee').
      out('Has').hasLabel('User').
      outE('HasRight).where(inV().as('c'))
© www.soinside.com 2019 - 2024. All rights reserved.