Search list with mutual count (2nd try)

前端 未结 2 1976
遥遥无期
遥遥无期 2020-11-30 15:56

I have created fresh dataset to explain my desired result. and here is the link

Or you can trigger this command using cypher.

create 
(_6  {UserName         


        
相关标签:
2条回答
  • 2020-11-30 16:20

    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.

    0 讨论(0)
  • 2020-11-30 16:36

    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
    
    0 讨论(0)
提交回复
热议问题