O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Related node to label

Suppose we want to add a label to the towers based on the country nodes. If the label is known with a static value, an example query is as follows:

MATCH (t:Tower)--(c:Country)SET t:HasCountry

This example makes little sense, but it shows you how to indicate any relation between two nodes. Therefore, it's worth it.

If the value of the label is dynamic, APOC is here to help--we already saw this procedure that can add an array of label.

This query will add the Country code as a label to the Tower nodes:

MATCH (t:Tower)--(c:Country)CALL apoc.create.addLabels(id(t), [c.code]) YIELD nodeRETURN node

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required