Skip to content

Instantly share code, notes, and snippets.

@benoitguigal
Created November 14, 2018 17:26
Show Gist options
  • Save benoitguigal/8b205215bdd36c7a4aa4feb75576fa71 to your computer and use it in GitHub Desktop.
Save benoitguigal/8b205215bdd36c7a4aa4feb75576fa71 to your computer and use it in GitHub Desktop.
import org.janusgraph.core.JanusGraphFactory
import org.janusgraph.core.Cardinality
import org.apache.tinkerpop.gremlin.structure.Vertex
// define the schema
graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')
mgmt = graph.openManagement()
mgmt.makeVertexLabel('person').make()
mgmt.makeEdgeLabel('is_linked_to').make()
entity = mgmt.makePropertyKey('entity').dataType(String.class).cardinality(Cardinality.SINGLE).make()
prenom = mgmt.makePropertyKey('prenom').dataType(String.class).cardinality(Cardinality.SINGLE).make()
nom = mgmt.makePropertyKey('nom').dataType(String.class).cardinality(Cardinality.SINGLE).make()
date_operation = mgmt.makePropertyKey('date_operation').dataType(String.class).cardinality(Cardinality.SINGLE).make()
valeur_euro = mgmt.makePropertyKey('valeur_euro').dataType(Double.class).cardinality(Cardinality.SINGLE).make()
mgmt.buildIndex('vertexByPrenomNom', Vertex.class).addKey(mgmt.getPropertyKey('prenomnom')).buildMixedIndex('search')
mgmt.buildIndex('vertexByEntity', Vertex.class).addKey(entity).buildCompositeIndex()
mgmt.commit()
graph.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment