2013-07-29 66 views
1

我试过以下查询在密码。Neo4j - 发生无效的查询错误

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 

那么,这个查询有什么问题?

回答

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; 

这应该是语法正确。我不完全确定你的查询想要做什么 - 它感觉不对,因为这两个查询没有连接在一起,因此你将得到othermeme/x的笛卡尔积在结果中。

+0

谢谢@ wes-freeman,请看看我的另一个问题。链接:http://stackoverflow.com/questions/17917884/join-result-set/17933098?noredirect=1#17933098 –