apoc.schema.properties.distinct

  • This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime. For more information, see the Cypher Manual → Parallel runtime.

  • Prior to the release of APOC 2025.07, this procedure was restricted on on-premise instances. To use it on an older version, it must be unrestricted. For more details, see Installation → Load and unrestrict.

Details

Syntax

apoc.schema.properties.distinct(label, key) :: (value)

Description

Returns all distinct NODE property values for the given key.

Input arguments

Name

Type

Description

label

STRING

The node label to find distinct property values on. If set to ``, the distinct property values for all labels will be found.

key

STRING

The name of the property to find distinct values of. If set to ``, the distinct property values for the specified label and all property names will be found.

Return arguments

Name

Type

Description

value

LIST<ANY>

The list of distinct values for the given property.

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.distinct("Person", "name");
Results
value

["Michael", "Ryan"]

All labels and specific property name

Setting the input argument label to `` will return the distinct property values for all labels and the specified property name.

CALL apoc.schema.properties.distinct("", "name");
Results
value

["Michael", "Ryan", "Shadow"]

Specific label and all property names

Setting the input argument key to `` will return the distinct property values for the specified label and all property names.

CALL apoc.schema.properties.distinctCount("Person", "");
Results
value

["Michael", "Ryan", 45, 33, 42]

All labels and all property names

Setting the input arguments label and key to `` will return the distinct property values for the all labels and property names.

CALL apoc.schema.properties.distinct("", "");
Results
value

["Michael", "Ryan", "Shadow", 45, 33, 42, 11]

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:

Changed behavior
Index on the label and key combination Property values Behavior before 2025.11 Behavior from 2025.11

No index

-

Without any index, the procedure would return an empty result.

The procedure will return the same result with and without an index, but might be slower without an index.

Multiple types of indexes

-

Could lead to an error depending on in which order the indexes were created

Will never cause an error

A non-range index

Mixed property types

Only property values of the same type as the index would be included in the result.

All property values will be included in the result.

A range index

Identical property values of type LIST

Each list would be considered distinct and gets included in the result.

The lists are considered the same value so they will only appear in the result once.

A range index

Property values created in the same transaction

Would not be included in the result

Will be included in the result

One or multiple range indexes

The label or key input arguments set to ``

Only label and property combinations covered by any of the indexes would be included in the result.

All relevant label and property combinations will be included in the result.