How connect Result nodes Neo4j

415 Views Asked by At

Neo4j has a tick box option 'connect results nodes' which i gather runs a second query to connect nodes after your initial query.

eg

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

This query returns 40 nodes which are connected to each other. While this works in the Neo4j browser, I cant quite get it to connect in Neo4j bloom. So question is whats the second query thats run to connect the result nodes under the hood?

Thanks

1

There are 1 best solutions below

0
On

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