I am quite new to janusgraph and I am in the process of indexing my graph.
Through the process I have discovered that we could index the edges like we index vertices.
FYI : I am indexing vertices using mixed - elastic search
This is the script that I have followed from the documentation
graph.tx().rollback()
mgmt = graph.openManagement()
type = mgmt.getPropertyKey('type')
has_reported = mgmt.getEdgeLabel('has_reported')
mgmt.buildEdgeIndex(has_reported, 'reportedByType', Direction.BOTH, Order.desc, type)
mgmt.commit()
ManagementSystem.awaitRelationIndexStatus(graph, 'reportedByType', 'has_reported').call()
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getRelationIndex(has_reported, "reportedByType"), SchemaAction.REINDEX).get()
mgmt.commit()
From the above script, here I have an edge 'has_reported' containing a property 'type'. After excuting the above script I had my edge 'REGISTERED' and successfully reindex with final status 'ENABLED' as below.
gremlin> mgmt.printIndexes()
==>------------------------------------------------------------------------------------------------
Vertex Index Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
byUserNameMixed | Mixed | false | search | username: ENABLED |
byPasswordMixed | Mixed | false | search | password: ENABLED |
byStatusIdComposite | Composite | false | internalindex | status_id: ENABLED |
---------------------------------------------------------------------------------------------------
Edge Index (VCI) Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Relation Index | Type | Direction | Sort Key | Order | Status |
---------------------------------------------------------------------------------------------------
reportedByType | has_reported | BOTH | type | desc | ENABLED |
---------------------------------------------------------------------------------------------------
Here I have confusion as I see three type of indexes shown
- Vertex Index Name
- Edge Index (VCI ) Name
- Relation Index
Need help on the following
- difference between Edge Index (VCI) Name and Relation Index
- how to index using 'Edge Index (VCI) Name' as I don't see that in the documentation
Documention referred : https://docs.janusgraph.org/schema/index-management/index-performance/#vertex-centric-indexes
Thanks!
CodePudding user response:
Edited (because the previous answer was not correct for more recent versions of JanusGraph):
I tend to agree that the naming of the JanusGraph indices used to be confusing (as in your question). In JanusGraph 0.6.2 the output of printIndexes() looks different:
gremlin> mgmt.printIndexes()
==>------------------------------------------------------------------------------------------------
Graph Index (Vertex) | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
name | Composite | true | internalindex | name: ENABLED |
vertices | Mixed | false | search | age: ENABLED |
byTestVal | Composite | false | internalindex | testval: ENABLED |
someName | Mixed | false | search | p: ENABLED |
| | | | q: ENABLED |
---------------------------------------------------------------------------------------------------
Graph Index (Edge) | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
edges | Mixed | false | search | reason: ENABLED |
| | | | place: ENABLED |
---------------------------------------------------------------------------------------------------
Relation Index (VCI) | Type | Direction | Sort Key | Order | Status |
---------------------------------------------------------------------------------------------------
battlesByTime | battled | BOTH | time | desc | ENABLED |
---------------------------------------------------------------------------------------------------
The Graph Index (Edge) enables a lookup among all edges in the graph database that have the label and key(s) needed for that relation index. This index is typically triggered with a query g.E().has(key, value)
.
A Relation Index (VCI-vertex centric index) enables a lookup among the matching edges bound to a single vertex. This index can only be triggered when first traversing to the associated vertex, like g.V().has(keyV, valueV).bothE(labelE).has(keyE, valueE)
. The vertex centric index enable you to traverse so-called supernodes that have very many connections.
You want the Graph Index (Edge), so you need to instantiate an index builder for that:
mgmt.buildIndex('reportedByType', Edge.class)
see the reference docs for further build steps.