密码分页总结果计数 [英] cypher pagination total result count

查看:58
本文介绍了密码分页总结果计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的密码查询,我需要对它的结果进行分页.我想要做的是在限制完成之前获得结果总数.

这是我的测试图:http://console.neo4j.org/?id=6hq9tj

我尝试在查询的所有部分使用 count(o),但总是得到相同的结果:'total_count: 1'.就像这里:http://console.neo4j.org/?id=konr7.我想要得到的结果应该是:'total_count: 6'.

我总是可以进行另一个查询来计算结果,但执行两个查询是没有意义的.

请问有人可以帮我解决这个问题吗?谢谢!

解决方案

这样的事情应该可行:

MATCH (o:Brand)带 o按姓名订购WITH collect({uuid:o.uuid, name:o.name}) AS 品牌,COUNT(distinct o.uuid) AS 总数UNWIND 品牌 AS brand_row总计,brand_row跳过 5限制 5RETURN COLLECT(brand_row) 作为品牌,总计;

<块引用>

注意:这是未经测试的,类似的东西对我有用.另外,不确定它的性能如何.

I have a monstrosity of a cypher query and I need to paginate the results of it. What I am trying to do is to get the total number of results before limit is done.

Here is my test graph: http://console.neo4j.org/?id=6hq9tj

I tried to use count(o) in all parts of the query but I always get the same result: 'total_count: 1'. Like in here: http://console.neo4j.org/?id=konr7. The result what I am trying to get should be: 'total_count: 6'.

I always could make an another query just to count the results but it makes no sense to execute two queries.

Please can any one help me one this? Thanks!

解决方案

Something like this should work:

MATCH (o:Brand)
WITH o
ORDER BY o.name 
WITH collect({uuid:o.uuid, name:o.name}) AS brands, COUNT(distinct o.uuid) AS total
UNWIND brands AS brand_row
WITH total, brand_row
SKIP 5
LIMIT 5
RETURN COLLECT(brand_row) AS brands, total;

Note: this is untested, something similar worked for me. Also, not sure how performant it is.

这篇关于密码分页总结果计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆