apoc.coll.indexOf

This function is deprecated. Use Cypher’s coll.indexOf() function instead.

Details

Syntax

apoc.coll.indexOf(coll, value)

Description

Returns the index for the first occurrence of the specified value in the LIST<ANY>.

Arguments

Name

Type

Description

coll

LIST<ANY>

The list to find the given value in.

value

ANY

The value to find the first occurrence of in the given list.

Returns

INTEGER

Usage examples

The following returns the index of the value 3 in the list using both APOC and Cypher:

apoc.coll.indexOf
RETURN apoc.coll.indexOf([1,3,5,7,9], 3) AS output;
Using Cypher’s coll.indexOf
RETURN coll.indexOf([1,3,5,7,9], 3) AS output;
Results
Output

1

The following returns -1 as it fails to find the value in the list using both APOC and Cypher:

apoc.coll.indexOf
RETURN apoc.coll.indexOf([1,3,5,7,9], 4) AS output;
Using Cypher’s coll.indexOf
RETURN coll.indexOf([1,3,5,7,9], 4) AS output;
Results
Output

3