Skip to content

Instantly share code, notes, and snippets.

@angryTit
Created July 21, 2017 12:23
Show Gist options
  • Save angryTit/3b1a4125fc72bc8b9e9bb395892caf92 to your computer and use it in GitHub Desktop.
Save angryTit/3b1a4125fc72bc8b9e9bb395892caf92 to your computer and use it in GitHub Desktop.
graph.tx().rollback();
TitanManagement titanManagement = graph.openManagement();
titanManagement.makeVertexLabel(USER_LABEL).make();
titanManagement.makeEdgeLabel(LIKE_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make();
titanManagement.makeEdgeLabel(DISLIKE_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make();
titanManagement.makeEdgeLabel(BLOCK_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make();
titanManagement.makeEdgeLabel(MATCH_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make();
titanManagement.makeEdgeLabel(SIMILAR_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make();
titanManagement.makePropertyKey(SIMILAR_WEIGHT).dataType(Integer.class).make();
PropertyKey propertyKeyUserId = titanManagement.makePropertyKey(USER_ID).dataType(Integer.class).make();
titanManagement.makePropertyKey(GENDER).dataType(String.class).make();
titanManagement.makePropertyKey(COUNTRY_CODE).dataType(String.class).make();
titanManagement.makePropertyKey(BIRTHDAY).dataType(String.class).make();
titanManagement.makePropertyKey(LAST_ACCESS).dataType(String.class).make();
titanManagement.makePropertyKey(CREATED_TIME).dataType(String.class).make();
titanManagement.makePropertyKey(HIDDEN).dataType(Boolean.class).make();
titanManagement
.buildIndex("byUserIdIndex", Vertex.class)
.addKey(propertyKeyUserId)
.unique()
.buildCompositeIndex();
titanManagement.commit();
ManagementSystem.awaitGraphIndexStatus(graph, "byUserIdIndex")
.status(SchemaStatus.ENABLED)
.call();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment