Vertex labels & indexes

106 views
Skip to first unread message

Jeff Callahan

unread,
May 23, 2018, 12:35:15 AM5/23/18
to JanusGraph users
Hi -

Each Vertex in my Graph has one label from the set "DC", "DS", "FC", "FL", "NL", and "ZIP".

What is the most efficient means to refer to the set of Vertexes with one of these labels?  For example, I'd like to create edges from each Vertex with label "FC" to each Vertex with label "ZIP".

I have used indexes for vertex properties with great results but it's not clear to me if those are available for Vertex label.  I see this example:

mgmt.buildIndex('byNameAndLabel', Vertex.class).addKey(name).indexOnly(god).buildCompositeIndex()

So, would I just omit the "addKey(...)" and use "indexOnly(...).buildCompositeIndex()" for each of the 6 different values of the vertex labels in my graph?  E.g., like so:

mgmt.buildIndex('byDCLabel', Vertex.class).indexOnly(dc).buildCompositeIndex()
mgmt.buildIndex('byDSLabel', Vertex.class).indexOnly(ds).buildCompositeIndex()
mgmt.buildIndex('byFCLabel', Vertex.class).indexOnly(fc).buildCompositeIndex()
mgmt.buildIndex('byFLLabel', Vertex.class).indexOnly(fl).buildCompositeIndex()
mgmt.buildIndex('byNLLabel', Vertex.class).indexOnly(nl).buildCompositeIndex()
mgmt.buildIndex('byZIPLabel', Vertex.class).indexOnly(zip).buildCompositeIndex()

Intuitively this doesn't feel right in the absence of the property - it feels like there should be a single index where the label itself should be the "property".

Thanks in advance for any suggestions or advice.

jeff.

Florian Hockmann

unread,
May 23, 2018, 2:47:28 AM5/23/18
to JanusGraph users
Hi Jeff,
what you are asking for is the ability to index vertices just by their label. This is currently not possible in JanusGraph but there exists a ticket for it: https://github.com/JanusGraph/janusgraph/issues/283

So your solution to simply omit the addKey() call doesn't work right now.

At the moment, you can only implement a workaround by adding either a property to those indices that you index and that holds those labels or by introducing a new vertex from which you add edges to all vertices of a certain label that you want to be able to find without knowing their properties.
Reply all
Reply to author
Forward
0 new messages