SimplePath 根据顶点属性省略某些路径

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

我有一个简单的图表,我试图从给定的顶点生成

path()

g.addV('ORG').as('1').
  property(single, 'orgId', 'f5c').addV('COMP').
    as('2').
  property(single, 'compId', 2112896).
  property(single, 'owner', 'def').addV('COMP').
    as('3').
  property(single, 'compId', 2100198).
  property(single, 'owner', 'def').addV('COMP').
    as('4').
  property(single, 'compId', 4007384).
  property(single, 'owner', 'def').addV('COMP').
    as('5').
  property(single, 'compId', 2106827).
  property(single, 'owner', 'abc').addV('COMP').
    as('6').
  property(single, 'compId', 2106829).
  property(single, 'owner', 'abc').addV('COMP').
    as('7').
  property(single, 'compId', 2104080).
  property(single, 'owner', 'abc').addV('COMP').
    as('8').
  property(single, 'compId', 2110851).
  property(single, 'owner', 'abc').addV('ORG').
    as('9').
  property(single, 'orgId', 28932).addE('edge').
  from('1').to('5').property('sub', '951a').
  addE('edge').from('1').to('2').
  property('sub', 5779).addE('edge').from('2').
  to('3').property('sub', 5779).addE('edge').
  from('3').to('4').property('sub', 5779).
  addE('edge').from('5').to('6').
  property('sub', '951a').addE('edge').
  from('6').to('7').property('sub', '951a').
  addE('edge').from('7').to('8').
  property('sub', '951a').addE('edge').
  from('4').to('9').property('sub', 1234).
  addE('edge').from('8').to('9').
  property('sub', 465474)

当我执行下面的查询时,我得到了 2 条不同的路径,这很好

g.V().has("orgId", "f5c")
.repeat(bothE().otherV().simplePath())
.until(hasLabel("ORG")).path().by(valueMap())

如果我们看到每个顶点都有一个名为

owner
的属性,在我的例子中我可以有多个所有者 问题 : 在获取路径时,我想过滤掉所有让我们说
owner != def
的路径,这意味着它只会返回所有者不是 def

的路径

我试过了

hasNot()

g.V().has("orgId", "f5c")
.repeat(bothE().otherV(hasNot("def")).simplePath())
.until(hasLabel("ORG")).path().by(valueMap())

但是没用

gremlin amazon-neptune tinkerpop3
© www.soinside.com 2019 - 2024. All rights reserved.