case insensitive search for labels

286 views Asked by At

Why this code doesn't work

MATCH (n) WHERE labels(n)=~ '(?i).*SUBSTRING.*' RETURN distinct labels(n)

Type mismatch: expected String but was Collection (line 1, column 17 (offset: 16))

But this does

match n-[r]-() where type(r)=~ '(?i).*SUBSTRING.*' return distinct type(r)
1

There are 1 answers

1
Dave Bennett On BEST ANSWER

labels(n) returns a collection and not a scalar. type(r) always returns a scalar as it is single valued.

Try labels(n)[0] instead and it should work.

Doing case insensitive substring matching on labels is not recommended in a large data set.