apoc.schema.relationships

Procedure

apoc.schema.relationships(config MAP<STRING, ANY>) - returns the indexes and constraints information for all the relationship types in the database. It is possible to define a set of relationship types to include or exclude in the config parameters.

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

Signature

apoc.schema.relationships(config = {} :: MAP) :: (name :: STRING, type :: STRING, properties :: LIST<STRING>, status :: STRING)

Input parameters

Name Type Default

config

MAP

{}

Config parameters

Table 1. Config parameters
name type default description

relationships

LIST<STRING>

[]

Relationship types to include. Default is to include all relationship types.

excludeRelationships

LIST<STRING>

[]

Relationship types to exclude. Default is to include all relationship types.

It’s not possible to valuate both relationships and excludeRelationships. In this case, the error Parameters relationships and excludeRelationships are both valued. will be returned.

Output parameters

Name Type

name

STRING

type

STRING

properties

LIST<STRING>

status

STRING

Usage Examples

The type result can have one of the following values:

Table 2. type output
name Schema type

"RELATIONSHIP_PROPERTY_EXISTENCE"

Relationship property existence constraints

"FULLTEXT"

Full-text index

"TEXT"

Text index

"RANGE"

Range index

"POINT"

Point index

"LOOKUP"

Lookup index

Community Edition example

Given the following schema:

CREATE FULLTEXT INDEX fullIdx FOR ()-[n:MOVIE|BOOK]-() ON EACH [n.title, n.description];

CREATE POINT INDEX pointIdx FOR ()-[n:PLACE]-() ON (n.address);

CREATE TEXT INDEX textIdx FOR ()-[n:GAME]-() ON (n.title);

CREATE RANGE INDEX rangeIdx FOR ()-[n:FOO_BAR]-() ON (n.name);

It is possible to execute the following query:

CALL apoc.schema.relationships()
Table 3. Results
name type properties status relationshipType

":PLACE(address)"

"POINT"

["address"]

"ONLINE"

"PLACE"

":GAME(title)"

"TEXT"

["title"]

"ONLINE"

"GAME"

":[BOOK, MOVIE],(title,description)"

"FULLTEXT"

["title", "description"]

"ONLINE"

["BOOK", "MOVIE"]

":FOO_BAR(name)"

"RANGE"

["name"]

"ONLINE"

"FOO_BAR"

Enterprise Edition example

Given the following schema:

CREATE CONSTRAINT likesDay
FOR ()-[like:LIKED]-()
REQUIRE (like.day) IS NOT NULL;

It is possible to execute the following query:

CALL apoc.schema.relationships()
Table 4. Results
name type properties status relationshipType

"CONSTRAINT ON ()-[liked:LIKED]-() ASSERT liked.day IS NOT NULL"

"RELATIONSHIP_PROPERTY_EXISTENCE"

["day"]

""

["BOOK", "MOVIE"]