Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we find all the labels available in a graph in JanusGraph?

I want to get the list of all the labels available in the graph, but I am unaware of the schema. Is there any way to find out the list of all the labels?

I have tried the following:

g.V().Label().values()
g.V().hasLabel().values()

but they are not working.

like image 889
Sagar Avatar asked Dec 13 '25 10:12

Sagar


1 Answers

In Gremlin you would do:

g.V().label().dedup()

but that would require a scan of all vertices in the graph which would be expensive. JanusGraph has schema you can query with the JanusGraphManagement class.

JanusGraphManagement mgmt = graph.openManagement();
Iterable<VertexLabel> labels = mgmt.getVertexLabels();
like image 80
stephen mallette Avatar answered Dec 16 '25 00:12

stephen mallette