Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-18-2021 10:30 PM
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!
08-19-2021 08:52 AM
Hi, you can access all nodes in the path via
`nodes(p) as nodes
List functions - Neo4j Cypher Manual
and then update all properties of the nodes with a map
SET - Neo4j Cypher Manual
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.
08-19-2021 12:12 PM
Hi,
With Cypher you want something like: (Notice you have no conditions on u. You may like some.
MATCH path=(u)-[*..]-(m)
WHERE all( n in nodes(path) where n:LabelYouDesire)
return path
With APOC is somethin like
MATCH (u)
WHERE 'INSERT U conditions here'
CALL apoc.path.expandConfig(u, {
labelFilter: "LABEL_YOU_DESIRE",
minLevel: 0
})
YIELD path
RETURN path;
H
08-19-2021 05:18 PM
This is exactly the code I want。Thank you very much!
All the sessions of the conference are now available online