apoc.schema.properties.distinctCountProcedure
|
Syntax |
|
||
Description |
Returns all distinct property values and counts for the given key. |
||
Input arguments |
Name |
Type |
Description |
|
|
The node label to count distinct properties on. If set to |
|
|
|
The name of the property to count distinct values of. If set to |
|
Return arguments |
Name |
Type |
Description |
|
|
The label of the node. |
|
|
|
The name of the property key. |
|
|
|
The distinct value. |
|
|
|
The number of occurrences of the value. |
|
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (:Person {name: "Michael", age: 45});
CREATE (:Person {name: "Ryan", age: 33});
CREATE (:Person {name: "Michael", age: 42});
CREATE (:Dog {name: "Shadow", age: 11});
Specific label and property name
CALL apoc.schema.properties.distinctCount("Person", "name");
| label | key | value | count |
|---|---|---|---|
"Person" |
"name" |
"Michael" |
2 |
"Person" |
"name" |
"Ryan" |
1 |
All labels and specific property name
Setting the input argument label to `` will return the distinct property values and counts for all labels and the specified property name.
CALL apoc.schema.properties.distinctCount("", "name");
| label | key | value | count |
|---|---|---|---|
"Person" |
"name" |
"Michael" |
2 |
"Person" |
"name" |
"Ryan" |
1 |
"Dog" |
"name" |
"Shadow" |
1 |
Specific label and all property names
Setting the input argument key to `` will return the distinct property values and counts for the specified label and all property names.
CALL apoc.schema.properties.distinctCount("Person", "");
| label | key | value | count |
|---|---|---|---|
"Person" |
"name" |
"Michael" |
2 |
"Person" |
"name" |
"Ryan" |
1 |
"Person" |
"age" |
45 |
1 |
"Person" |
"age" |
33 |
1 |
"Person" |
"age" |
42 |
1 |
All labels and all property names
Setting the input arguments label and key to `` will return the distinct property values and counts for the all labels and property names.
CALL apoc.schema.properties.distinctCount("", "");
| label | key | value | count |
|---|---|---|---|
"Person" |
"name" |
"Michael" |
2 |
"Person" |
"name" |
"Ryan" |
1 |
"Dog" |
"name" |
"Shadow" |
1 |
"Person" |
"age" |
45 |
1 |
"Person" |
"age" |
33 |
1 |
"Person" |
"age" |
42 |
1 |
"Dog" |
"age" |
11 |
1 |
|
In APOC 2025.11, this procedure went through a bigger refactoring including several bug fixes. As a result the behavior has changed compared to previous versions in multiple cases:
|