简体   繁体   中英

Referencing property in Gremlin query

I'm trying to do a query that looks somewhat like this:

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

Where me.identifier would be changed to something that actually works. I just have no clue how to reference the property value of "identifier"

Let's first consider what your query:

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

says in English: "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"

Now, maybe that's not exactly what you want. For some reason, I gather that you want to: "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'" in which case it's:

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

But then I also gather than you might want to: "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'" in which case it's:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM