I have a vertex, say:
Vertex vertex = g.addV("person")
.property("name", "x")
.property(VertexProperty.Cardinality.list, "email", "x@yahoo.com")
.property(VertexProperty.Cardinality.list, "email", "x@gmail.com")
.next();
I am fetching values from the vertex using:
g.V(vertex).valueMap(true).by(unfold()).next();
I get:
{id=f862aa64-70d3-4c85-9bd0-1c938fdc2dc8, label=person, name=x, email=x@yahoo.com}
I wish to extract all the values of the property email, hence I do not want that apply unfold() to that property alone, how do I add this condition?
Also, I wish to do this in the one query itself.
You can unfold
the valueMap
by the number of values:
g.V().valueMap().by(choose(
count(local).is(eq(1)),
unfold()
identity()
))
example: https://gremlify.com/bpy7apfj4yncr
Or you can use a simple project
:
g.V().project('name', 'email').
by(values('name')).
by(values('email').fold())
example: https://gremlify.com/bqatjfi3rmrmt