1
我那裏有代表的職位post
節點和comment
節點上的帖子代表的意見圖形模型:暗號查詢返回節點的計數與結果不同的屬性值
(p:post)<-[:ON]-(c:comment{role:'question'})
(p:post)<-[:ON]-(c:comment{role:'criticism'})
每個註釋具有role
屬性,它是五個可能值之一。我想編寫一個查詢,以返回給定計劃中每個角色的評論總數。
此:
MATCH (:item:initiative{urlCode:'AAECyS'})<-[:TO]-(c:comment) WITH
COLLECT(c) AS comments
RETURN {
question:length(filter(x IN comments WHERE x.role = 'question')),
criticism:length(filter(x IN comments WHERE x.role = 'criticism'))
//etc. for other three types
}
給我我想要的東西 - 但感覺非常醜陋的我。
有沒有更清潔/更有效的方法來做到這一點?