0
我希望我的朋友与友谊状态的相互数。我为每个用户创建了节点,并创建了它们之间属性的关系。根据以下查询,我找到了我想要的结果。在这个测试用例中,我的登录用户ID = 1,我想搜索那些从字母'dh'开始的用户。所以,我的查询如下。加入结果集
1st Query : which is returned all users with specific given keyword.
--------------------------------------------------------------------
START other=node(*)
WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1
WITH other, me=node:node_auto_index(UserID = '1')
RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath
LIMIT 100;
该查询返回了我所有的用户开始使用“卫生署” 现在,我想我的登录用户之间友谊的地位和本搜索用户。所以,我做这个如下:
2nd Query : which is returned approvalstatus between user1 and other
--------------------------------------------------------------------
START me=node:node_auto_index(UserID = '1')
MATCH me-[myR:friends]-(x)
RETURN x.UserID, myR.ApprovalStatus
ORDER BY x.UserID
最后,我需要按照下面的查询用户1和其他人之间的共同好友数。
3rd Query : which is returned mutual count between user1 and other
------------------------------------------------------------------
START me=node:node_auto_index(UserID = '1'), other=node(*)
MATCH pMutualFriends=me-[r:friends]-mf-[r1:friends]-other
WHERE r.ApprovalStatus = 1
AND r1.ApprovalStatus = 1
AND other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1
RETURN other.UserID, COUNT(pMutualFriends) AS mutualCount
ORDER BY other.UserID
现在我想加入所有这个查询,就像我们在RDBMS中一样。表示结果集1st应该返回所有记录,并加入第二个结果集&。
我该怎么做?
谢谢@爱德华,您的查询看起来对我非常有用。但有一件事是不存在的。我需要以'dh'开头的所有节点。这里在你的查询中只返回连接到用户1的那些节点,而我也想从关系中获得“ApprovalStatus”属性。你能帮我取得理想的结果吗? –
嗨@edward,我们可以用userid加入3个结果集吗?像RDBMS一样加入。所以,所有节点都来自结果1,结果2有'ApprovalStatus',结果3来自'MutualCount'。你明白我的意思了吗?等待你的回复。谢谢。 –
我正在努力理解您所要求的数据问题。它是“查找所有名称以'dh'开头的用户,并将他们与朋友分享的每个人的共同朋友计数返回给他们。”? – Edward