There's something I don't get with cypher queries and multiple match.
Context :
target = node(2145) = video game on the app
me = node(2570) = user logged in
I'm trying to get all the users (including me) that interacted with the given target. Furthermore, I want these users to be ordered by distance between them and me...
i.e. The goal is to display the users that interacted with the video game : me and my friends first, and then the others.
My query :
START target=node(2145), me=node(2570)
MATCH (target)-[:INTERACTIONS]->()<-[:IS_TARGET_OF]-(interactions)<-[:IS_SOURCE_OF]-()<-[:INTERACTIONS]-(users)
WITH me, users
MATCH p = (users)-[:CONTACTS]->()-[?:IS_FRIEND_WITH*0..3]-()<-[:CONTACTS]-(me)
RETURN users, MIN(LENGTH(p)) as conn
ORDER BY conn ASC
Issue :
Considering I'm the only one that interacted with the target, I should get one result : 2570.
The issue I have is that I don't see 'me' in the returned users : the query returns nothing
What I tried :
- If I RETURN right after the first MATCH, I get one result : 2570.
if, in the second match, I try p = (users)-[*0..3]-(me), I also get one result : 2570.
If I only take the second part of the query to try the following :
START me=node(2570), users=node(2570, 2802) MATCH p = me-[:CONTACTS]->()-[?:IS_FRIEND_WITH*0..3]-()<-[:CONTACTS]-(users) RETURN users, MIN(LENGTH(p)) as conn ORDER BY conn ASC
I get 2570 and 2802 (because he's my friend).
I'm sure I'm doing something wrong here, but I can't see what..Do you have any idea how I could solve my issue?
Thanks,