Search list with mutual count (2nd try)

早过忘川 提交于 2019-11-27 05:42:17
bendaizer

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.

What about this? http://console-test.neo4j.org/?id=8lloq1

START me=node:node_auto_index(UserProfileID = '1'), other=node(*) 
MATCH pMutualFriends=me-[r?:friends]-mf-[r1?:friends]-other 
WHERE other.UserName! =~ '(?i)dh.*' AND other.UserProfileID? <> 1 AND r.ApprovalStatus=1 
RETURN DISTINCT (other.UserProfileID?),ID(other),me.EMailID?, other.EMailID?, other.UserName?, r.ApprovalStatus, COUNT(pMutualFriends) AS mutualCount
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!