neo4j - 查询错误:预期Float或Integer但是Node

时间:2014-10-04 22:01:19

标签: neo4j cypher

我有这些标签:

  • 简档

现在我正在尝试此查询:

OPTIONAL MATCH
    (pag:page),
    (pag)-[:AUTHOR]-(pos:post),
    (pos)-[:LIKED]-(likers:prof)
RETURN
    pag.name,
    count(pos)  AS totalPagePosts,
    sum(likers) AS totalPageLikes

然后我收到此错误:

File ":9:9": Type mismatch: expected Float or Integer but was Node (line 9, column 9)
"sum(likers) AS totalPageLikes"

我该如何进行此查询?

1 个答案:

答案 0 :(得分:1)

请使用如下查询:

OPTIONAL MATCH
    (pag:page),
    (pag)-[:AUTHOR]-(pos:post),
    (pos)-[:LIKED]-(likers:prof)
RETURN
    pag.name,
    count(distinct pos) AS totalPagePosts,
    count(distinct likers) AS totalPageLikes

Sum()是一个汇总函数,用于汇总数值,count()只计算出现的次数。

请参阅Cypher Ref Card