Skip to content

Latest commit

 

History

History
113 lines (72 loc) · 1.96 KB

Management API.md

File metadata and controls

113 lines (72 loc) · 1.96 KB

The JanusGraph management API

Using management API, we can define the following,

  • Edge,
  • Vertex
  • Property schema types
  • Index.

Manage by Gremlin

Connect to gremlin and open session

 ./gremlin.sh 

:remote connect tinkerpop.server conf/remote.yaml session

:remote console

mgmt = graph.openManagement()

# mgmt.commit()

Print Schema

mgmt.printSchema()

Define Vertex schema

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

Creating Vertex Label

mgmt.makeVertexLabel('user').make()
mgmt.commit()

Defining edge labels and usage

Allowed usages are

  • MULTI - default
  • MANY2ONE
  • ONE2MANY
  • ONE2ONE
  • SIMPLE
mgmt.makeEdgeLabel('contains').multiplicity(SIMPLE).make()
mgmt.commit()

Creating a property with cardinality

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()}

Drop database

? 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);