liveBook · Manning

Set clause

As explained in Graph Algorithms for Data Science

A SET clause is a Cypher clause that assigns or updates node labels and node or relationship properties.

The SET clause updates node labels and properties on nodes or relationships. It commonly follows MATCH and WHERE to identify existing graph elements before changing them. section 3.1.4

Use SET to make several kinds of graph updates:

  • Apply a map of properties with +=; this preserves existing properties while adding or updating the supplied entries. section 3.1.4
  • Replace all existing properties with a supplied map by using = instead of +=. section 3.1.4
  • Add secondary node labels, such as Student or Employee, to create semantically distinct retrieval groups. section 3.1.4

Updating a person

MATCH (t:Person) WHERE t.name = 'Satish' SET t.interest = 'Gardening', t.hungry = True

How Graph Algorithms for Data Science covers it

How deep it goes
Explains individual assignments, map updates, replacement semantics, and secondary labels, without covering optimization internals.
Examples
Uses Satish and Elaine property updates, a Student label, and customer funnel-stage labels.
What you can do after
Apply it via Cypher to update properties, replace property maps, and add labels to matched nodes.
How it connects
Connects SET with MATCH, WHERE, maps, node labels, properties, REMOVE, DELETE, and MERGE.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.