I am confused about how collect works when I unwind it.
I am collecting node properties from various optional matches and ending up with list that has duplicates:
list=[
[ID: 1, value: 0],
[ID: 1, value: 4],
[ID: 1, value: 90],
[ID: 2, value: 40],
[ID: 2, value: 0],
...,
]
I can't collect just the nodes - it has to be a list because the values are computed as I collect them.
UNWIND list AS node
WITH distinct node
Unwind above does not bring it down to just one row for ID: 1, which I understand because at this point the list items are different and not related to the ID: 1 node anymore.
I'd like to only keep the row with the highest value for each ID. Can this be done on the RETURN?
Expected result: [[ID: 1, value: 90], [ID: 2, value: 40]]
I looked at apoc list and map functions but nothing seems to address this. Is there a reduce or coalesce type thing that would work?
TIA!