apoc.nodes.group
Procedure APOC Core
Signature
apoc.nodes.group(labels :: LIST? OF STRING?, groupByProperties :: LIST? OF STRING?, aggregations = [{*=count}, {*=count}] :: LIST? OF MAP?, config = {} :: MAP?) :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?, node :: NODE?, relationship :: RELATIONSHIP?)
Input parameters
| Name | Type | Default | 
|---|---|---|
labels  | 
LIST? OF STRING?  | 
null  | 
groupByProperties  | 
LIST? OF STRING?  | 
null  | 
aggregations  | 
LIST? OF MAP?  | 
[{=count}, {=count}]  | 
config  | 
MAP?  | 
{}  | 
Output parameters
| Name | Type | 
|---|---|
nodes  | 
LIST? OF NODE?  | 
relationships  | 
LIST? OF RELATIONSHIP?  | 
node  | 
NODE?  | 
relationship  | 
RELATIONSHIP?  | 
Usage Examples
The examples in this section are based on the following sample graph:
CREATE
 (alice:Person {name:'Alice', gender:'female', age:32, kids:1}),
 (bob:Person   {name:'Bob',   gender:'male',   age:42, kids:3}),
 (eve:Person   {name:'Eve',   gender:'female', age:28, kids:2}),
 (graphs:Forum {name:'Graphs',    members:23}),
 (dbs:Forum    {name:'Databases', members:42}),
 (alice)-[:KNOWS {since:2017}]->(bob),
 (eve)-[:KNOWS   {since:2018}]->(bob),
 (alice)-[:MEMBER_OF]->(graphs),
 (alice)-[:MEMBER_OF]->(dbs),
 (bob)-[:MEMBER_OF]->(dbs),
 (eve)-[:MEMBER_OF]->(graphs);
CALL apoc.nodes.group(
  ['*'],
  ['gender'],
  [{`*`:'count', age:'min'}, {`*`:'count'} ]
)
YIELD relationships
UNWIND relationships as rel
RETURN apoc.rel.startNode(rel) AS start, rel, apoc.rel.endNode(rel) AS end;
| start | rel | end | 
|---|---|---|
(:Person {gender: "female", min_age: 28,   | 
[:MEMBER_OF {  | 
(:Forum {gender: NULL,   | 
(:Person {gender: "female", min_age: 28,   | 
[:KNOWS {  | 
(:Person {gender: "male", min_age: 42,   | 
(:Person {gender: "female", min_age: 28,   | 
[:KNOWS {  | 
(:Person {gender: "male", min_age: 42,   | 
(:Person {gender: "male", min_age: 42,   | 
[:MEMBER_OF {  | 
(:Forum {gender: NULL,   |