Using management API, we can define the following,
- Edge,
- Vertex
- Property schema types
- Index.
Connect to gremlin and open session
./gremlin.sh
:remote connect tinkerpop.server conf/remote.yaml session
:remote console
mgmt = graph.openManagement()
# mgmt.commit()
mgmt.printSchema()
List all vertex label
mgmt.getVertexLabels()
List all edge label
mgmt.getRelationTypes(EdgeLabel.class)
List all properties key
mgmt.getRelationTypes(PropertyKey.class)
Cardinality of a property
mgmt.getPropertyKey('name').cardinality()
==>SINGLE
Data type of property
gremlin> mgmt.getPropertyKey('name').dataType()
==>class java.lang.String
Existence of a label
mgmt.containsEdgeLabel('route')
true
mgmt.containsVertexLabel('user')
true
mgmt.makeVertexLabel('user').make()
mgmt.commit()
Allowed usages are
- MULTI - default
- MANY2ONE
- ONE2MANY
- ONE2ONE
- SIMPLE
mgmt.makeEdgeLabel('contains').multiplicity(SIMPLE).make()
mgmt.commit()
Allowed cardinalities are
- SINGLE - default
- LIST
- SET
mgmt.makePropertyKey('name').dataType(String.class).cardinality(LIST).make()
mgmt.commit()
###Display the property keys along with their data types and cardinality settings
types = mgmt.getRelationTypes(PropertyKey.class)
types.each{println "$it\t: " + mgmt.getPropertyKey("$it").dataType() + " " + mgmt.getPropertyKey("$it").cardinality()}
? If you are running multiple janus, change the properties file path
gremlin> graph = JanusGraphFactory.open('/opt/janusgraph-1.0.0/conf/janusgraph-cql.properties')
==>standardjanusgraph[cql:[127.0.0.1]]
gremlin> JanusGraphFactory.drop(graph);