Neo4j - Invalid Query error occured

对着背影说爱祢 提交于 2020-01-05 10:18:26

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17917508/neo4j-invalid-query-error-occured

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!