apoc.coll.occurrences函数在 Cypher 25 中已弃用
使用示例
以下示例演示了如何分别使用 APOC 和 Cypher 统计列表中值 9 出现的次数
apoc.coll.occurrences
WITH [1,3,5,7,9,9] AS list, 9 AS match
RETURN apoc.coll.occurrences(list, match) AS output
使用 Cypher 的 reduce()
WITH [1,3,5,7,9,9] AS list, 9 AS match
RETURN reduce(count = 0, x IN list | count + CASE WHEN x = match THEN 1 ELSE 0 END) AS output
| 输出 |
|---|
2 |