I'm using gremlin Python to query a Neptune DB. Given a vertices, I need to return all the outward edges with their 'from' and 'to' ids, label and any other properties.
The query below
query_result = g.V().has('name', 'marco').outE().inV().path().toList()
gives me the 'from' and 'to' in a form i can parse into a list of dicts, and a value map of the edge gives me the other values but i need it returned in a single list. my ideal format is [{from: x, to: y, label: foo, property1: bar},...]
Any help greatly appreciated.
You can do it with elementMap
step:
g.V().has('name', 'marko').outE().inV().
path().
by(elementMap())
EDIT:
if elementMap
not supported you can specify what you want to get from vertices and edges separately using by
steps. there you can create any data format you want with project
g.V().has('name', 'marko').outE().inV().
path().
by(valueMap(true)).by(union(
project('from', 'to').
by(outV().id()).
by(inV().id()),
valueMap(true)
).unfold().
group().by(keys).
by(select(values).unfold()))
example: https://gremlify.com/ab