Star

统计属性的比例

nebula怎么统计边上某属性的属性值比例?
例:有一个属性为A,属性值为a,b,c三种取值,我想统计边表edge中每个属性值a,b,c分别对应的边的比例是多少

目前需要在客户端得到属性值后做统计计算

do u want to count all the edges of edgeType A or just count the edges related to a specific node. The latter scenario can be implemented using group by.

Assuming there are 4 edges of follow type connects to node 100.

INSERT EDGE follow(degree) VALUES 100 -> 101:(95);
INSERT EDGE follow(degree) VALUES 100 -> 102:(90);
INSERT EDGE follow(degree) VALUES 100 -> 103:(90);
INSERT EDGE follow(degree) VALUES 100 -> 104:(70);

Then query:

> go from 100 over follow yield follow.degree as degree, follow._dst as id | group by $-.degree yield $-.degree, count($-.id)

============================
| $-.degree | COUNT($-.id) |
============================
| 95        | 1            |
----------------------------
| 75        | 1            |
----------------------------
| 90        | 2            |
----------------------------

浙ICP备20010487号