在 Gremlin 查询中引用 属性

Referencing property in Gremlin query

我正在尝试做一个看起来有点像这样的查询:

g.V('myId').as('me').out('member').hasLabel('myLabel').in('member').has('identifier', 'me.identifier')

其中 me.identifier 将更改为实际有效的内容。我只是不知道如何引用 "identifier"

的 属性 值

让我们首先考虑一下您的查询:

g.V('myId').as('me').
  out('member').hasLabel('myLabel').
  in('member').has('identifier', 'me.identifier')

用英语说:"find a vertex with the id of 'myId', then traverse outgoing 'member' edges to vertices that have the label of 'myLabel', then traverse incoming 'member' edges to vertices that have a property value of 'me.identifier' for the 'identifier' property"

现在,也许这并不是您想要的。出于某种原因,我了解到您想:"find a vertex with the id of 'myId', then traverse outgoing 'member' edges to vertices that have the label of 'myLabel', then traverse incoming 'member' edges to vertices that have an id of 'myId'" 在这种情况下是:

g.V('myId').
  out('member').hasLabel('myLabel').
  in('member').hasId('myId')

但是我还收集了一些你可能想要的:"find a vertex with the id of 'myId', then traverse outgoing 'member' edges to vertices that have the label of 'myLabel', then traverse incoming 'member' edges to vertices that have an identifier property with the same value of as the 'identifier' property of the start vertex with 'myId'" 在这种情况下它是:

g.V('myId').as('me').
  out('member').hasLabel('myLabel').
  in('member').as('them').
  where('them', eq('me')).
    by('identifier')