Skip to content

Instantly share code, notes, and snippets.

@NhuanTDBK
Last active August 1, 2018 04:53
Show Gist options
  • Save NhuanTDBK/999bc2b8773c1076c1ab6241d4bfb2e1 to your computer and use it in GitHub Desktop.
Save NhuanTDBK/999bc2b8773c1076c1ab6241d4bfb2e1 to your computer and use it in GitHub Desktop.
janusgraph_index
graph = JanusGraphFactory.open("conf/gremlin-server/janusgraph-cql-es.properties")
mgmt = graph.openManagement()
mgmt.makePropertyKey("shop_id").dataType(Long.class).cardinality(Cardinality.SINGLE).make()
mgmt.makePropertyKey("ref_id").dataType(Long.class).cardinality(Cardinality.SINGLE).make()
mgmt.commit()
mgmt = graph.openManagement()
shopID = mgmt.getPropertyKey("shop_id")
refId = mgmt.getPropertyKey("ref_id")
mgmt.buildIndex("ByShopID",Vertex.class).addKey(shopID).buildCompositeIndex()
mgmt.buildIndex("ByShopIDAndRefID",Vertex.class).addKey(shopID).addKey(refId).unique().buildCompositeIndex()
mgmt.commit()
System.out.println("Indexing is created")
ManagementSystem.awaitGraphIndexStatus(graph,"ByShopID").call()
ManagementSystem.awaitGraphIndexStatus(graph,"ByShopIDAndRefID").call()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment