在neo4j cypher查询中获取分页前的行数

时间:2015-12-02 15:05:24

标签: neo4j datatables cypher

我在显示neo4j的结果时遇到了一些问题。我使用服务器端jquery数据表,我需要在其中定义iTotalDisplayRecords,它是过滤后产生的记录数。我的密码查询是这样的:

UNWIND {json} as data
WITH data
WHERE (data.entry =~ {searchText} OR ....)
RETURN { entry: data.entry, name: data.name, .... }
ORDER BY {field} ASC SKIP {offset} LIMIT {number}

所以,我需要在应用LIMIT之前记录的数量,但是我无法找回该号码,任何人都可以帮我解决这个问题吗?

提前谢谢

1 个答案:

答案 0 :(得分:1)

天真的想法:您可以添加WITHcount(*)作为聚合,并将数据收集到稍后会UNWIND编辑的集合中:

UNWIND {json} as data
WITH data
WHERE (data.entry =~ {searchText} OR ....)
WITH count(*) as count, collect(data) as dataColl
UNWIND dataColl as d
RETURN { entry: d.entry, name: d.name, .... , count: count}
ORDER BY {field} ASC SKIP {offset} LIMIT {number}