Neo4j 限制非常数

Neo4j limit with non-constant

我想问一下是否可以限制一段查询返回的节点为非常数,这意味着 - 我希望限制取决于查询返回的某个变量,例如邻居计数的 30%节点。

有点丑,但是这样的呢?

MATCH n-[:type]->(neighbor)
WITH n, toInt(count(neighbor) * 0.3) AS limit
MATCH n-[:type]->(neighbor)
WITH n, collect(neighbor)[1..limit] AS neighbors
UNWIND neighbors AS neighbor
RETURN n, neighbor