Neo4j - Invalid Query error occured

2019-08-04 01:36发布

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?

标签: neo4j cypher
1条回答
可以哭但决不认输i
2楼-- · 2019-08-04 02:00

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.

查看更多
登录 后发表回答