0

I want to count how many vertices (nodes) are in the graph:

gremlin>g.V().count().next()
Could not find a suitable index to answer graph query and graph scans are disabled: [(~label = user)]:VERTEX

Gremlin.version() is 3.2.9

I use janusGraph hbase to store data, es to store index.

But some query is ok like this:

gremlin> g.V().has('user_id','47357061').values('real_name')
==>jack

I don't understand why I can't query the count.

currarpickt
  • 2,290
  • 4
  • 24
  • 39

1 Answers1

1

JanusGraph simply cannot answer that traversal without iterating over all vertices. It doesn't store the count as a separate value in the backend so it actually has to compute the count for this traversal which means iterating over all vertices.

The warning you see just informs you about this fact and advises you to only execute traversals that can be executed by using an index as all other traversals will run into scalability issues if your graph grows.

If you really need the functionality to execute traversals that cannot make use of an index as they have to traverse over all vertices in your graph (or a large number of vertices), then you should look into Hadoop-Gremlin which uses Spark to execute such a traversal in parallel with multiple Spark workers.

Florian Hockmann
  • 2,634
  • 13
  • 24
  • Thanks for you answer Now i trying to use hadoop. – jack_json Jul 10 '19 at 07:22
  • Please update the link.When I open that link , the page is rendering 404 not found – Himabindu Feb 07 '20 at 07:26
  • @FlorianHockmann,thanks for updating the link. I am having a bit of confusion. I have two vertices say A and B. when I query for A vertex like ``g.V().hasLabel('A').has('key',false).count()`` is giving me the count. And the property key is composite index. same scenario for vertex B but rather than getting the count I am getting an error **Could not find a suitable index to answer graph query and graph scans are disabled: [(~label = B)]:VERTEX** – Himabindu Feb 07 '20 at 10:40
  • @Himabindu Please create a new question for this or ask on janusgraph-users as it's a completely different issue. It is however not a good idea to create an index on a property of type Boolean as an index should only match on a small number of elements. In general, it sounds however like you only enabled the index for label 'A' and not 'B', but again, if you need further help, comments of an existing answer aren't the right place for that. – Florian Hockmann Feb 07 '20 at 15:11
  • @FlorianHockmann, I have created a new question. Could you please checkout [How to build index for newly created property](https://stackoverflow.com/questions/60116799/how-to-build-index-for-already-present-property) – Himabindu Feb 07 '20 at 15:54