apoc.schema.relationships

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.

Details

Syntax

apoc.schema.relationships([ config ]) :: (name, type, properties, status, relationshipType)

Description

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.

Input arguments

Name

Type

Description

config

MAP

{ labels :: LIST<STRING>, excludeLabels :: LIST<STRING>, relationships :: LIST<STRING>, excludeRelationships :: LIST<STRING> }. The default is: {}.

Return arguments

Name

Type

Description

name

STRING

A generated name for the index or constraint.

type

STRING

The type of the index or constraint.

properties

LIST<STRING>

The property keys associated with the constraint or index.

status

STRING

The status of the constraint or index.

relationshipType

ANY

The relationship type associated with the constraint or index.

Config parameters

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.

Usage Examples

The type result can have one of the following values:

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()
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()
Results
name type properties status relationshipType

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

"RELATIONSHIP_PROPERTY_EXISTENCE"

["day"]

""

["BOOK", "MOVIE"]