Reputation: 379
I am able to count nodes by property using apoc, with this query
CALL apoc.nodes.group(['Package'],['Repository'])
yield nodes
return nodes
I can see that the Repository
field is returned with a _count
property
Now I'd like to return just those two properties in my query, but I don't see how ...
I've tried
CALL apoc.nodes.group(['Package'],['Repository'])
yield nodes
return nodes.Repository, nodes._count;
but I get
Type mismatch: expected Any, Map, Node or Relationship but was List<Node> (line 3, column 8
(offset: 77))
"return nodes.Repository, nodes._count;"
^
Upvotes: 0
Views: 273
Reputation: 20185
The result of the apoc.nodes.group
procedure is not a single node but a list of nodes, as you can see in the error message.
You can just unwind them and return the result :
CALL apoc.nodes.group(['Package'],['Repository'])
YIELD nodes
UNWIND nodes AS node
RETURN node.Repository, node._count;
Upvotes: 1