我正在處理圖數據庫並寫了一些Cypher查詢。Cypher查詢中聯合後的結果(Neo4j)
e.g以下查詢是針對特定用戶的所有帖子和查詢的其他部分每個人喜歡的總量不計算
第一部分也類似。
查詢
match a=(p:FaceBookPost{auther_id:"1"})-[hv:HAVE_LIKE]-(l:FacebookLike)
return COUNT(l.auther_id) as total, (l.auther_id) as authers order by total DESC
UNION ALL
match a=(p:FaceBookPost{auther_id:"1"})-[hv:HAVE_COMMENT]-(l:FacebookComment)
return COUNT(l.auther_id) as total, (l.auther_id) as authers order by total DESC
UNION ALL
match a=(i:InstagramPost{person_id:"1"})-[il:INSTAGRAM_LIKE]-(l:InstagramLike)
return COUNT(i.person_id) as total, (l.person_id) as authers order by total DESC
UNION ALL
match a=(i:InstagramPost{person_id:"1"})-[ic:INSTAGRAM_COMMENT]-(c:InstagramComment)
return COUNT(c.person_id) as total, (c.person_id) as authers order by total DESC
輸出地說:
| total | authers
---+-------+---------
1 | 4 | author 1
2 | 3 | author 2
3 | 1 | author 3
4 | 2 | author 1
5 | 1 | author 2
6 | 1 | author 3
. | . | ........
. | . | ........
. | . | ........
必出放:
| total | authers
---+-------+---------
1 | 6 | author 1
2 | 4 | author 2
3 | 2 | author 3
我已經嘗試了不同的方式和不同的查詢要求輸出。 但我無法得到任何解決方案。
Cypher中有任何方法可以獲得所需的輸出嗎?
正如你所說的更新模型在我的情況下是不可能的。 我也在將數據從RDMS遷移到圖形數據庫。 –
我試圖看看在從RDBMS遷移之後是否可以找到更新模型的方法,因爲它可以簡化所有查詢。如果你不能這樣做,你需要後處理聯合的結果 - 直到鏈接的github問題得到解決。 –
感謝您的回覆,但在我的情況下,建模不可能以這種方式進行。因爲我還必須添加twitter數據。 它們有完全不同的型號。 –