3

我的模型是这样的:(wine_critic)-[REVIEW]->(wine_bottle)

wine_critic 可以对同一个 wine_bottle 进行多次评论(他们不知道,这是盲品),每条评论都有时间戳和分数

因此,我想获得某个 wine_critic 对 wine_bottle 的评论总数,以及同一评论家对同一瓶的 MAX/MIN 分数。

START critic=node:critics('ID:5')
MATCH (critic)-[rev:REVIEW]->(bottle)
WITH critic, bottle, COUNT(rev) as total_reviews
RETURN critic.name, bottle.name, total_reviews

而且,在同一个查询中,我想要 MAX(rev.score) 和 MIN(rev.score)。

可能吗?

4

1 回答 1

2

在这种情况下,您实际上并不需要 WITH:

START critic=node:critics('ID:5')
MATCH (critic)-[rev:REVIEW]->(bottle)
RETURN critic.name, bottle.name, COUNT(rev) as total_reviews, MAX(rev.score) as max, MIN(rev.score) as min

不妨也扔进AVG(rev.score)STDEV(rev.score)

更新:1.8.x 中丑陋的解决方法:

START critic=node:critics('ID:5')
MATCH (critic)-[rev:REVIEW]->(bottle)
WITH critic, bottle, MIN(rev.score) as min
MATCH (critic)-[rev:REVIEW]->(bottle)
RETURN critic.name, bottle.name, COUNT(rev) as total_reviews, MAX(rev.score) as max, min
于 2013-09-10T18:59:51.820 回答