简体   繁体   中英

Neo4j limit with non-constant

我想问问是否可以用非常量限制查询的一部分返回的节点,这意味着-我希望限制依赖于查询返回的某些变量,例如邻居节点计数的30%。

It's a bit ugly, but what about something like this?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM