-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_setup.txt
84 lines (76 loc) · 4.91 KB
/
index_setup.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# The following commands should be pasted into Gremlin console to set up
# indexing when a Gremlin server is FIRST CREATED.
# These commands add:
# composite index on "name" for vertices: g.V().has('name', ...)
# composite index on "category" for vertices: g.V().has('category', ...)
# composite index for "category" THEN "name" for vertices:
# g.V().has('category', ...).has('name', ...)
# mixed index on "start_time" THEN "end_time" for edges:
# g.E().hasLabel('connection').has('start_time', ...).has('end_time', ...)
# a LIST cardinality on the "values" attribute of vertices (for property vertices)
# Read more here: https://docs.janusgraph.org/index-management/index-performance/
:remote connect tinkerpop.server conf/remote.yaml session
:remote console
mgmt = graph.openManagement()
# Properties. The ones for which we record the return value for (e.g., active,
# category) we will also create indices for since they tend to be used for searches.
name = mgmt.makePropertyKey('name').dataType(String.class).make()
active = mgmt.makePropertyKey('active').dataType(Boolean.class).make()
category = mgmt.makePropertyKey('category').dataType(String.class).make()
start = mgmt.makePropertyKey('start_time').dataType(Long.class).make()
end = mgmt.makePropertyKey('end_time').dataType(Long.class).make()
mgmt.makePropertyKey('start_uid').dataType(String.class).make()
mgmt.makePropertyKey('start_comments').dataType(String.class).make()
mgmt.makePropertyKey('start_edit_time').dataType(Long.class).make()
mgmt.makePropertyKey('end_uid').dataType(String.class).make()
mgmt.makePropertyKey('end_comments').dataType(String.class).make()
mgmt.makePropertyKey('end_edit_time').dataType(Long.class).make()
mgmt.makePropertyKey('time_added').dataType(Long.class).make()
mgmt.makePropertyKey('uid_added').dataType(String.class).make()
mgmt.makePropertyKey('time_disabled').dataType(Long.class).make()
mgmt.makePropertyKey('uid_disabled').dataType(String.class).make()
mgmt.makePropertyKey('replacement').dataType(String.class).make()
mgmt.makePropertyKey('comments').dataType(String.class).make()
mgmt.makePropertyKey('units').dataType(String.class).make()
mgmt.makePropertyKey('allowed_regex').dataType(String.class).make()
mgmt.makePropertyKey('n_values').dataType(Long.class).make()
mgmt.makePropertyKey('values').dataType(String.class).cardinality(Cardinality.LIST).make()
# Edges
connection = mgmt.makeEdgeLabel("rel_connection").make()
mgmt.makeEdgeLabel("rel_property").make()
mgmt.makeEdgeLabel("rel_version").make()
mgmt.makeEdgeLabel("rel_version_allowed_type").make()
mgmt.makeEdgeLabel("rel_component_type").make()
mgmt.makeEdgeLabel("rel_subcomponent").make()
mgmt.makeEdgeLabel("rel_property_type").make()
mgmt.makeEdgeLabel("rel_property_allowed_type").make()
mgmt.makeEdgeLabel("rel_flag_component").make()
mgmt.makeEdgeLabel("rel_flag_type").make()
mgmt.makeEdgeLabel("rel_flag_severity").make()
mgmt.makeEdgeLabel("rel_user_group").make()
mgmt.makeEdgeLabel("rel_group_permission").make()
# Indices, for fast searching.
mgmt.buildIndex('byCategoryComposite', Vertex.class).addKey(category).buildCompositeIndex()
mgmt.buildIndex('byActiveComposite', Vertex.class).addKey(active).buildCompositeIndex()
mgmt.buildIndex('byNameComposite', Vertex.class).addKey(name).buildCompositeIndex()
mgmt.buildIndex('byNameAndActiveComposite', Vertex.class).addKey(name).addKey(active).buildCompositeIndex()
mgmt.buildIndex('byCategoryAndActiveComposite', Vertex.class).addKey(category).addKey(active).buildCompositeIndex()
mgmt.buildIndex('byCategoryAndActiveAndNameComposite', Vertex.class).addKey(category).addKey(active).addKey(name).buildCompositeIndex()
mgmt.buildIndex('byCategoryAndNameMixed', Vertex.class).addKey(category).addKey(name).buildMixedIndex("search")
mgmt.buildIndex('startAndEndMixed', Edge.class).addKey(start).addKey(end).indexOnly(connection).buildMixedIndex("search")
mgmt.buildIndex('byActiveCompositeEdge', Edge.class).addKey(active).buildCompositeIndex()
mgmt.commit()
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex("byNameComposite"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byActiveComposite"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byActiveCompositeEdge"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byCategoryComposite"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byCategoryAndNameMixed"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("startAndEndMixed"), SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byNameAndActiveComposite"),SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byCategoryAndActiveComposite"),SchemaAction.REINDEX).get()
mgmt.updateIndex(mgmt.getGraphIndex("byCategoryAndActiveAndNameComposite"),SchemaAction.REINDEX).get()
mgmt.commit()
mgmt = graph.openManagement()
#vals = mgmt.makePropertyKey('values').dataType(String.class).cardinality(org.janusgraph.core.Cardinality.LIST).make()
mgmt.commit()