Index labels of vartices

663 views
Skip to first unread message

troj...@gmail.com

unread,
Nov 7, 2017, 11:42:41 AM11/7/17
to JanusGraph users
Is there a plan to make possibility to index labels of vertices in JanusGraph?

Ankur Goel

unread,
Nov 9, 2017, 6:42:25 AM11/9/17
to JanusGraph users
 add one property with label name and index it.

troj...@gmail.com

unread,
Nov 10, 2017, 11:16:48 AM11/10/17
to JanusGraph users
Thank you Ankur. It is definitly good solution, but in this case what are the pros of using labels at all?

Tomek

HadoopMarc

unread,
Nov 10, 2017, 4:50:01 PM11/10/17
to JanusGraph users
Hi Tomek,

The label has no use for selecting the traversal starting point, indeed. You can use it later on in the traversal, though. E.g. in g.V().has('name', 'Pete'),out().hasLabel('person'), Pete's friends are retrieved by Id, because the starting vertex is stored/retrieved together with the id's of connected vertices (the so-called star graph object).

Cheers,     Marc

Op vrijdag 10 november 2017 17:16:48 UTC+1 schreef troj...@gmail.com:

Bhawesh Agarwal

unread,
Dec 2, 2017, 5:39:57 AM12/2/17
to JanusGraph users
Hi Marc,
I have query regarding your answer. If we can not index label then why we get warning to create index?
Here is query I used

gremlin> g.V().has(T.label,'instance')

16:00:10 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [(~label = instance)]. For better performance, use indexes

==>v[4200]

==>v[4272]


gremlin> g.V().hasLabel('instance')

16:00:55 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [(~label = instance)]. For better performance, use indexes

==>v[4200]

==>v[4272]

HadoopMarc

unread,
Dec 2, 2017, 8:12:15 AM12/2/17
to JanusGraph users
Hi Bhawesh,

g.V().has(T.label,'instance') needs a full table scan to resolve which is very slow for large graphs. With g.V().has('indexedproperty', 'somevalue') and indexedproperty an indexed property JanusGraph can simply lookup somevalue in the index and get the corresponding vertexid very fast.

In practice, you will create indices for some of your properties and you may forget for which properties an index exists. The warning helps you remembering.

Cheers,     Marc

Op zaterdag 2 december 2017 11:39:57 UTC+1 schreef Bhawesh Agarwal:
Reply all
Reply to author
Forward
0 new messages