Labels are used to represent the properties of nodes and edges. You can categorize the nodes and edges based on the semantic meaning of properties.
Specify multiple labels in a statement
Separate multiple labels by using | as shown in the following sample code:
(n:Person|Company)
[p:KNOWS|LIKES]Prepare test data
SELECT create_graph('imdb');
SELECT *
FROM cypher('imdb', $$
CREATE (toby:actor {name: 'Toby Maguire'}),
(willam:director {name: 'Willam Dafoe'}),
(hanks:person {name: 'Tom Hanks'}),
(spiderman:movie {title: 'Spiderman'}),
(toby)-[:acted_in]->(spiderman),
(willam)-[:directed]->(spiderman),
(hanks)-[:likes]->(spiderman)
$$) AS (a agtype);Examples
Query the names with either the
actorordirectorlabel.SELECT * FROM cypher('imdb', $$ MATCH (a:actor|director) RETURN a.name $$ ) as (name agtype);Sample result:
name ---------------- "Toby Maguire" "Willam Dafoe" (2 rows)Query the individuals who are related to the movie
Spidermanin either thedirectedoracted_inrelationship.SELECT * FROM cypher('imdb', $$ MATCH (p)-[r:acted_in|directed]->(:movie {title: 'Spiderman'}) RETURN p.name $$ ) as (name agtype);Sample result:
name ---------------- "Toby Maguire" "Willam Dafoe" (2 rows)