Search list with mutual count (2nd try)

As I said in my comment, trying to query for connected and disconnected nodes at the same time doesn’t seem to be a good idea.

If you want only connected nodes, try the following query :

START me=node:node_auto_index(UserName="manish") 
MATCH me-[:friends]-mf-[:friends]-other, me-[r?]-other 
WHERE other.UserName! =~ '(?i)dh.*' 
RETURN DISTINCT ID(other), r.ApprovalStatus AS status, count(mf) AS mutual, ID(me) 
ORDER BY mutual DESC , status ASC

Please note that I had to add another pattern in the match clause, because your approval status is between (me) and (other), and not between (me) and (mutual friend), which is what you were doing!

This will return the first 3 lines of your expected answer and ignores dhansukh.

Leave a Comment