Reputation: 469
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
Upvotes: 4
Views: 802
Reputation: 2856
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())
Upvotes: 0