I have tried following query in cypher.
START other=node(*)
WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1
WITH other, me=node:node_auto_index(UserID = '1')
MATCH me-[myR:friends]-(x)
RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath
// myR.ApprovalStatus, COUNT(distinct pMutualFriends) AS mutualFriends
//ORDER BY mutualFriends DESC
LIMIT 100;
but it is giving me error.
These columns can't be listen in the WITH statement without renaming: me=node
so, What is wrong with this query?
You need to do another START clause to do this:
START other=node(*)
WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1
WITH other
START me=node:node_auto_index(UserID = '1')
MATCH me-[myR:friends]-(x)
RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath
// myR.ApprovalStatus, COUNT(distinct pMutualFriends) AS mutualFriends
//ORDER BY mutualFriends DESC
LIMIT 100;
That should be syntactically correct. I'm not exactly sure what your query is trying to do--it doesn't feel right, because the two queries are not linked together with a match
, so you're going to get the cartesian product of other
and me
/x
in the results.