0

I am running a Gremlin query against Neptune 1.1.1.0. For development purposes, I'm trying to remove a vertex with a specific phone number along with its related Subscription and Channel vertices. I have a union statement that correctly emits the desired vertices in the Gremlin console, and I can apply elementMap() to print out all the properties:

gremlin> g.V()
  .hasLabel('Identity').has('phones', '+11234567890'))
  .union(
    identity(),
    __.out('Receives').hasLabel('Subscription'), 
    __.out('MemberOf').hasLabel('Channel')
  )
==>v[d5bc0f8a-a5a5-4209-8bbf-43ea1c39a694]
==>v[d0183e2b-74a8-446c-b378-903dcfc5f50f]
==>v[aba2577f-9244-4367-bcb6-209b9fbe4548]
gremlin> g.V()
  .hasLabel('Identity').has('phones', '+11234567890'))
  .union(
    identity(),
    __.out('Receives').hasLabel('Subscription'), 
    __.out('MemberOf').hasLabel('Channel')
  ).elementMap()
==> // prints out properties for each of the 3 vertices

However, if I apply drop() to the query, the first (Identity) vertex is dropped, but not the subsequent ones. I expected that when I had a traversal with multiple matching vertices, all of them would be dropped (e.g., g.V().hasLabel('Identity').has('phones', startingWith('+1')).drop() drops all North American vertices). Why is Neptune/Gremlin stopping at the first vertex in this case?

gremlin> g.V()
  .hasLabel('Identity').has('phones', '+11234567890'))
  .union(
    identity(),
    __.out('Receives').hasLabel('Subscription'), 
    __.out('MemberOf').hasLabel('Channel')
  ).drop()

(I would generally attempt to run an explain here to get more information, but I don't know how to make that work with drop() as a final step.)

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152

1 Answers1

0

I'm taking a deeper look at this, it looks very familiar, but I'm not quite remembering the behavior here.

I can also reproduce this with just TinkerGraph and Gremlin console.

For now, as a work around, try doing fold().unfold().drop()

I'm pretty sure I have seen this before and there may even be a TinkerPop Jira open for it. I'll do some more research and update this answer if I find anything relevant. Hopefully for now you at least have a workaround.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38