In the Modern graph, I want to get for each person the name and the list of names of software he created. So I tried the following query
g.V().hasLabel('person').project('personName','softwareNames').
by(values('name')).
by(out('created').values('name').aggregate('a').select('a'))
but I get the error
The provided traverser does not map to a value: v[2]->[VertexStep(OUT,[created],vertex), PropertiesStep([name],value), AggregateStep(a), SelectOneStep(last,a)]
The problem seems to be that vertex 2 has no "created" edges.
The query works if I run it only on vertices with at least one "created" edge, e.g. for vertex 4 ("V(4)" instead of "V()"), the result is
==>[personName:josh,softwareNames:[ripple,lop]]
How can I get an empty list of software names for vertex 2, instead of the error?
You can simplify your Gremlin to this:
The
by()
modulator only does anext()
on the inner traversal passed to it, so you need to reduce the results yourself - in this casefold()
does that and handles the situation where you have an empty result.