我有一个等级(比如1到103)和一个密码中每个等级的节点数。
day.name rank count
12/14/2016 1 1
12/14/2016 2 2
12/14/2016 3 3
12/14/2016 4 10
...
12/14/2016 11 20000
12/14/2016 12 20500
...
12/14/2016 21 15000
12/14/2016 22 15000
我希望在列中显示摘要数据,例如排名为1到3,排名为4到10的计数等。
在此示例中,所需的结果为
'rank_1_to_3' 'rank_4_to_10' 'rank_11_to_20' 'rank_21_to_100'
---------------------------------------------------------------------------
6 10 40500 30000
这里是Cypher:
match (d:Domain {name:'hotelguides.com'})
match (c:Temp {name:"top30k_rank_1_to_100"})
match (day:Day {name:'2016-12-22'})
match (day)-[]-(kua:KeywordURLAssociation)-[]-(d)
match (k:Keyword)-[]-(kua)-[]-(r:Rank)
with day, kua, r, k return day.name, r.name, count(k)
答案 0 :(得分:0)
我认为此查询可以帮助您入门。我将把它应用到你的特定领域。实质上,您可以使用filter
将结果集合过滤到具有这些结果子集的另一个集合中。对于每个较小的结果,您可以使用reduce
来汇总该集合。像这样......
with [
{name:'12/14/2016', rank:1, count:1},
{name:'12/14/2016', rank:2, count:2},
{name:'12/14/2016', rank:3, count:3},
{name:'12/14/2016', rank:4, count:10},
{name:'12/14/2016', rank:11, count:20000},
{name:'12/14/2016', rank:12, count:20500},
{name:'12/14/2016', rank:21, count:15000},
{name:'12/14/2016', rank:22, count:15000}
] as days
return reduce(sum_c=0, d in filter(d in days where d.rank < 4) | sum_c + d.count) as rank_1_3
, reduce(sum_c=0, d in filter(d in days where d.rank > 3 and d.rank < 11) | sum_c + d.count) as rank_4_to_10
, reduce(sum_c=0, d in filter(d in days where d.rank > 10 and d.rank < 21) | sum_c + d.count) as rank_11_to_20
, reduce(sum_c=0, d in filter(d in days where d.rank > 20 and d.rank < 101) | sum_c + d.count) as rank_21_100