4

I am trying to get the count of all vertices with a particular label and all its children in one query like so:

g.V().hasLabel('folder').has('folder_name', 'root').as_('a', 'b').select('a', 'b').by(__.count()).by(__.in_('items_belongs_to_folder').count()).toList()

This should ideally return [{a: 200, b: 400}], but I am instead getting a list like so:

[{a: 1, b: 0},{a: 1, b: 0},{a: 1, b: 0},{a: 1, b: 0},{a: 1, b: 0},{a: 1, b: 0},{a: 1, b: 0},....{a: 1, b: 0}]

How exactly can I achieve the desired result?

gremlinpython: 3.4.4 (latest)

Python 3.7

graph database: AWS Neptune

Raghav Jajodia
  • 419
  • 4
  • 6

1 Answers1

0

You can try:

g.V().hasLabel('folder').has('folder_name', 'root').fold()
.project('a', 'b')
.by(count(local))
.by(unfold().in_('items_belongs_to_folder').count())
noam621
  • 2,766
  • 1
  • 16
  • 26