How do I report on nodes with multiple labels

If your data model has choosen to define multiple labels on a node, for example

create (n:Actor:Director {name:'Clint Eastwood'})

To find all nodes which are defined with both labels of Actor AND Director use the following Cypher:

match (n) where n:Actor and n:Director return n;

Using this syntax will be performant as it will start with a NodeByLabelScan

If you need to find all nodes which have either label of Actor OR Director use the following Cypher:

MATCH (n:Actor) RETURN n UNION MATCH (n:Director) RETURN n

Using this syntax will be performant as it will perform a NodeByLabelScan on both the Actor label and the Director label and then merge the results. ”’

  • Last Modified: 2020-08-03 16:12:21 UTC by Dana Canzano.
  • Relevant for Neo4j Versions: 2.3, 3.0.
  • Relevant keywords labels.