Reputation: 407
I have following structure in a Janusgraph database:
gremlin> continent = g.addV("continent").property("name", "Europe").next()
gremlin> country = g.addV("country").property("name", "France").next()
gremlin> region = g.addV("region").property("name", "Ile-de-France").next()
gremlin> departement = g.addV("departement").property("name", "Hauts-de-Seine").next()
gremlin> city = g.addV("city").property("name", "Saint-Cloud").next()
gremlin> g.V(continent).addE('is_part_of').to(country).iterate()
gremlin> g.V(country).addE('is_part_of').to(region).iterate()
gremlin> g.V(region).addE('is_part_of').to(departement).iterate()
gremlin> g.V(departement).addE('is_part_of').to(city).iterate()
I did to get the property name
from all vertices from city to continent from the following query:
gremlin> g.V(city).emit().repeat(inE("is_part_of").outV().simplePath()).path().unfold().dedup().values("name")
==>Saint-Cloud
==>Hauts-de-Seine
==>Ile-de-France
==>France
==>Europe
But I would like to get also the id
and the label
of every returned vertex.
I tried to use valueMap(true)
instead of values("name")
step to get all properties including id
and label
, but big part of vertices contain lot of properties which could be heavy in the level of performance.
Is it possible to get those values from each vertex?
Upvotes: 3
Views: 474
Reputation: 46206
You could just do valueMap(true, 'name')
gremlin> g.V(city).emit().repeat(inE("is_part_of").outV().simplePath()).
......1> path().
......2> unfold().
......3> dedup().
......4> valueMap(true,'name')
==>[id:8,label:city,name:[Saint-Cloud]]
==>[id:13,label:is_part_of]
==>[id:6,label:departement,name:[Hauts-de-Seine]]
==>[id:12,label:is_part_of]
==>[id:4,label:region,name:[Ile-de-France]]
==>[id:11,label:is_part_of]
==>[id:2,label:country,name:[France]]
==>[id:10,label:is_part_of]
==>[id:0,label:continent,name:[Europe]]
Upvotes: 3