18

How to write a CYPHER query that returns only those nodes that do not have labels attached to them? I tried:

match (n:) return n

Invalid input ')': expected whitespace or a label name (line 1, column 10) "match (n:) return n" ^

Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75

1 Answers1

37

In Neo4j < 2.3:

MATCH n
WHERE length(labels(n)) = 0
RETURN n

In Neo4j >= 2.3:

MATCH (n)
WHERE size(labels(n)) = 0
RETURN n
Nicole White
  • 7,720
  • 29
  • 31