Categorize

The available procedure is described in the table below:

CALL apoc.refactor.categorize(sourceKey, type, outgoing, label, targetKey, copiedKeys, batchSize)

turn each unique propertyKey into a category node and connect to it

Example Usage

The example below will help us learn how to use this procedure.

The following creates nodes with a favoriteColor property:
CREATE (:Person {name: "Mark", favoriteColor: "Red"})
CREATE (:Person {name: "Jennifer", favoriteColor: "Blue"})
CREATE (:Person {name: "David", favoriteColor: "Red"})
The following turn all favoriteColor properties into FAVORITE_COLOR relationships to Color nodes with a matching color property.
CALL apoc.refactor.categorize('favoriteColor', 'FAVORITE_COLOR', true, 'Color', 'color', [], 100)

If we execute this query, it will result in the following graph:

apoc.categorize