# Set the label attributes of all nodes

**URL:** <https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123>\
**Category:** Procedures & APOC\
**Tags:** apoc\
**Created:** [August 19, 2021, 5:30am UTC](https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123 "2021-08-19T05:30:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruanlovelin](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ruanlovelin/32/720_2.png) [@ruanlovelin](https://community.neo4j.com/u/ruanlovelin)\
**Post date:** [August 19, 2021, 5:30am UTC](https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123/1 "2021-08-19T05:30:44Z")

</div>

In "match path=(u)-[\*..]-(m) return path", I want to set or limit the label attributes of all nodes in the path, please tell me how to do it 。Thank you very much!

---

<div class="post-metadata">

**Author:** ![apankraz](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/apankraz/32/9504_2.png) [@apankraz](https://community.neo4j.com/u/apankraz)\
**Post date:** [August 19, 2021, 3:52pm UTC](https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123/2 "2021-08-19T15:52:06Z")

</div>

Hi, you can access all nodes in the path via

`nodes(p) as nodes

[List functions - Neo4j Cypher Manual](https://neo4j.com/docs/cypher-manual/current/functions/list/#functions-nodes)  
and then update all properties of the nodes with a map  
[SET - Neo4j Cypher Manual](https://neo4j.com/docs/cypher-manual/current/clauses/set/#set-replace-properties-using-map)

Example:  
match path=(u)-[\*..]-(m)  
with nodes(path) as nodes  
unwind nodes as n  
SET n = {name: 'Peter Smith', position: 'Entrepreneur'}

this would reset all properties on the nodes with a name and position property. All preexisting properties will be removed.

---

<div class="post-metadata">

**Author:** ![Bennu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bennu/32/11659_2.png) [@Bennu](https://community.neo4j.com/u/Bennu)\
**Post date:** [August 19, 2021, 7:12pm UTC](https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123/3 "2021-08-19T19:12:21Z")

</div>

Hi,

With Cypher you want something like: (Notice you have no conditions on _u_. You may like some.

```auto
MATCH path=(u)-[*..]-(m) 
WHERE all( n in nodes(path) where n:LabelYouDesire)
return path

```

With APOC is somethin like

```auto
MATCH (u)
WHERE 'INSERT U conditions here'
CALL apoc.path.expandConfig(u, {
	labelFilter: "LABEL_YOU_DESIRE",
    minLevel: 0
})
YIELD path
RETURN path;

```

H

---

<div class="post-metadata">

**Author:** ![ruanlovelin](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ruanlovelin/32/720_2.png) [@ruanlovelin](https://community.neo4j.com/u/ruanlovelin)\
**Post date:** [August 20, 2021, 12:18am UTC](https://community.neo4j.com/t/set-the-label-attributes-of-all-nodes/43123/4 "2021-08-20T00:18:59Z")

</div>

This is exactly the code I want。Thank you very much!
