Query to Connect Result Nodes

HI all ,

I'm running into an issue which is the opposite of what most people want when using the Neo4j Browser.

Given a simple query like this just returns top 40 users, in the browser I can chekc the Connect Result nodes box to show the relationships between the nodes in the result set. I understand this is a second query done under the hood. My question is how would I reproduce it in cypher. The idea is to save this query in Neo4j bloom so i can get top 40 users and the relationships between them. I've tried referencing (n) as a subquery but cant get a way to quite do it.

match (n:User)
where n.Verified = 'false'
return n
order by n.followers DESC
Limit 40

Thank you

For anyone who falls into the same problem. The answer is a subquery which checks if node ids are in the original set. In the first query you return a list of node ids using the built in ID function, then collect the nodes. In the subquery you unwind the nodes and in the subquery where clause filter the using the list of IDs.

Match (b:User)
where b.Verified = 'false' and b.followers > 60
with collect(b) as users, collect(ID(b)) as listUsers
CALL{
  with users,listUsers
  unwind users as x
  match(x)-[r]-(c:User)
  where ID(c) in listUsers
  return x,r,c
  }
return x,r,c
1 Like