获取聚合模式

get the mode of an aggregation

我正在学习 neo4j,我被要求通过评论找到与用户相关的最常见的业务类别。由于类别实际上并不存在于数据中,而且实际上只有一项业务,因此我使用 name 代替。但是我这样做的方式并没有给我想要的东西:

MATCH (u:User {name: "Willie"})-[:WROTE]-(:Review)-[:REVIEWS]-(b:Business) 
  RETURN b.name, count(b.name)
  ORDER BY count(b.name)
  LIMIT 1

不对的地方:

MATCH (u:User {name: "Willie"})-[:WROTE]-(:Review)-[:REVIEWS]-(b:Business)
  RETURN mode(b.name)

您可以使用变量计数 (b.name) 并且 return 通过使用“WITH”子句仅使用名称。

MATCH (u:User {name: "Willie"})-[:WROTE]-(:Review)-[:REVIEWS]-(b:Business) 
  WITH b.name as name, count(b.name) as cnt ORDER BY cnt desc
  RETURN name LIMIT 1