apoc.schema.relationship.indexExists

  • This function 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 function 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.relationship.indexExists(type, propertyName)

Description

Returns a BOOLEAN depending on whether or not an index exists for the given RELATIONSHIP type with the given property names.

Arguments

Name

Type

Description

type

STRING

The relationship type to check for an index on.

propertyName

LIST<STRING>

The property names to check for an index on.

Returns

BOOLEAN

Example

Given this index:

CREATE INDEX knows_since FOR ()-[r:KNOWS]-() ON (r.since);
CREATE INDEX purchased_composite FOR ()-[r:PURCHASED]-() ON (r.date, r.amount);

The following query checks whether an index exists on the since property of KNOWS relationships:

RETURN apoc.schema.relationship.indexExists('KNOWS', ['since']) AS indexExists
Results
indexExists

true

Passing a property that is not indexed, or a type with no index at all, returns false:

RETURN apoc.schema.relationship.indexExists('KNOWS', ['unknown']) AS indexExists
Results
indexExists

false

Composite indexes require all property names to be supplied in the correct order:

RETURN apoc.schema.relationship.indexExists('PURCHASED', ['date', 'amount']) AS indexExists
Results
indexExists

true