-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtpclassic-titan-schema.groovy
24 lines (24 loc) · 1.22 KB
/
tpclassic-titan-schema.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def defineTinkerPopClassicSchema(titanGraph) {
m = titanGraph.openManagement()
// vertex labels
person = m.makeVertexLabel("person").make()
project = m.makeVertexLabel("project").make()
// edge labels
knows = m.makeEdgeLabel("knows").make()
created = m.makeEdgeLabel("created").make()
// v/e props
name = m.makePropertyKey("name").dataType(String.class).make()
namelist = m.makePropertyKey("namelist").dataType(String.class).cardinality(Cardinality.LIST).make()
git = m.makePropertyKey("git").dataType(String.class).make()
nameset = m.makePropertyKey("nameset").dataType(String.class).cardinality(Cardinality.SET).make()
weight = m.makePropertyKey("weight").dataType(Float.class).make()
age = m.makePropertyKey("age").dataType(Integer.class).make()
lang = m.makePropertyKey("lang").dataType(String.class).make()
// indices
m.buildIndex("peopleByName", Vertex.class).addKey(name).indexOnly(person).buildCompositeIndex()
m.buildIndex("projectsByName", Vertex.class).addKey(name).indexOnly(project).buildCompositeIndex()
// vindices
m.buildEdgeIndex(knows, "knowsByWeight", Direction.BOTH, Order.decr, weight)
m.buildEdgeIndex(created, "createdByWeight", Direction.BOTH, Order.decr, weight)
m.commit()
}