Hi,
I stumbled over an interesting problem. I have a simple tree of items that are part of other items. We need to find out in an efficient manner (and that's why we use neo4j) if some composite item (= has parts) is compliant with a certain norm, depending on the question if all of its parts are compliant.
I want to use a reduce formula for a logical AND connection between all the part's compliance.
So here's the query that *almost* answers all our questions:
match (b:part)-[r:PART_OF*]->(c) where c.num='511164-0890'
with collect(b) as bb, b, c
return
b.name as Part, b.ynum as `Part number`, b.is_compliant as compliant,
c.name as Product, reduce(all_compliant=true, bbb in bb | all_compliant=true AND bbb.compliant=1) as `all_compliant`
The only problem is that my collection collects only ONE item, the one that is presented in the row of my table.
If I leave the individual parts out of the return, I get what I want:
match (b:part)-[r:PART_OF*]->(c) where c.num='511164-0890'
with collect(b) as bb, c
return
c.name as Product, reduce(all_compliant=true, bbb in bb | all_compliant=true AND bbb.compliant=1) as `all_compliant`
Is there a way to bind a collection to some variable outside the loop, so that I can display individual parts without reinitializing the collection for each row, and still be able to use the reduce statement for the *general* compliance?
Thanks for any input,
best regards,
Christoph
--