In Neo4J I have the following problem:
Nodes are arranged in a tree-like or parent/child style structure. On the "leafs" or child nodes, every node has a set of nummerical attributes.
I need a Cypher query to calculate the average of each attribute and strore it in an attribute with the same name in the parent node.
Something like
MATCH (p:Parent)-[]->(c:Child)
SET p.attrib1 = avg(c.attrib1)
SET p.attrib2 = avg(c.attrib2)
will do the job, BUT...
The amount of attributes in the child-nodes should be dynamic, I do not want to change the code when a Child-node comes up with an additional attribute name. As long as the property is a decimal, the code should adapt to this.
Is there a way to achieve this?
Child
nodes share the same set of numerical properties? And are there anyChild
properties that you do not want to average? – cybersam