Predicate function Any doesn't work in a RETURN

Hi all,

Can any one tells me why the predicated function "any" only works in a "WHERE" and not with "RETURN" ?

//Works
MATCH(cables:Cables)
WHERE any(x IN cables.connectedFrom WHERE x=false)
RETURN count(cables)

//Doesn't work
MATCH(cables:Cables)
RETURN count(any(x IN cables.connectedFrom WHERE x=false))

Data set:

// 01. Delete all
MATCH (all) DETACH DELETE all;

CREATE (cable1:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable2:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"2", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable3:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"3", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable4:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"4", connectedFrom:TRUE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable5:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable6:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});
CREATE (cable7:Cables {length:0, cableType:"Local", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable8:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"2", connectedFrom:TRUE, connectedTo:TRUE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable9:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"3", connectedFrom:FALSE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable10:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"4", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable11:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable12:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});

Predicate any() is meant to produce a boolean value (as all predicates do by definition), it's not capable of discarding elements. Hence, your query returns the total number of nodes labeled as Cable.

And it doesn't seem like you need list predicates like any() here.

Maybe that's what you were trying to achieve?

MATCH (c:Cables)
WHERE c.connectedFrom
RETURN count(c);

Also, I doubt whether connectedFrom and connectedTo should be node's properties (consider expressing this information through the graph structure).

Alexanderv:

Thanks for your response.
Understand better what the meaning of "Any" is.

Just wondering why it didn't work.

Kind regards.