I am trying to create a user vertex and a city vertex (if they do not already exist in the graph), and then add an edge between the two of them. When I execute the command in the same traversal, I run into this InternalFailureException
from Neptune.
g.V("user12345").
fold().
coalesce(unfold(),addV("user").property(id, "user-12345")).as('user').
V("city-ATL").
fold().
coalesce(unfold(), addV("city").property(id, "city-ATL")).as("city").
addE("lives_in").
from("user").
to("city")
{"code":"InternalFailureException","detailedMessage":"An unexpected error has occurred in Neptune.","requestId":"xxx"}
(Note in the case above, both user-12345
and city-ATL
do not exist in the graph).
However, when I create the city before executing the command, it works just fine:
gremlin> g.V("city-ATL").
fold().
coalesce(unfold(),
addV("city").property(id, "city-ATL"))
==>v[city-ATL]
gremlin> g.V("user-12345").
fold().
coalesce(unfold(),addV("user").property(id, "user-12345")).as('user').
V("city-ATL").
fold().
coalesce(unfold(), addV("city").property(id, "city-ATL")).as("city").
addE("lives_in").from("user").to("city")
==>e[1abd87d6-6f54-9e42-ae0a-47401c9dcfe6][user-12345-lives_in-city-ATL]
I am trying to build a traversal that can do them both together. Does anyone know why Neptune might be throwing this InternalFailureException
when the city doesn't exist?
I will investigate further why you did not get a more useful error message but I can see that the Gremlin query will need to change. After a fold
step any prior as
labels are lost as fold
reduces the traversers down to one. A fold
is both a barrier and a map. You should be able to use store
or aggregate(local)
instead of as
in this case where you have to use fold
for each coalesce
.
gremlin> g.V('user-1234').
......1> fold().
......2> coalesce(unfold(),addV('person').property(id,'user-1234')).store('a').
......3> V('city-ATL').
......4> fold().
......5> coalesce(unfold(),addV('city').property(id,'city-ATL')).store('b').
......6> addE('lives_in').
......7> from(select('a').unfold()).
......8> to(select('b').unfold())
==>e[0][user-1234-lives_in->city-ATL]