Neo4j - 发生无效查询错误

时间:2013-07-29 06:41:35

标签: neo4j cypher

我在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;

但它给了我错误。

These columns can't be listen in the WITH statement without renaming: me=node

所以,这个查询出了什么问题?

1 个答案:

答案 0 :(得分:2)

您需要执行另一个START子句来执行此操作:

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;

这应该在语法上是正确的。我不确定您的查询尝试做什么 - 感觉不对,因为这两个查询没有与match链接在一起,因此您将获得{的笛卡尔积<1}}和other / me在结果中。