我正在尝试显示有多少用户从一个视图列表中查看过一次,两次......的内容。
看起来像是:
1 view: 1000 users
2 views: 100 users
3 views: 10 users
...
我可以像这样获得每个用户的观看量:
//request
{
"size": 0,
"aggs": {
"views per token": {
"terms": {
"field": "browsertoken",
"size": 0,
"order": {
"_count": "desc"
}
}
}
}
}
//returns
{
"took": 61,
"timed_out": false,
...
"hits": {
"total": 215642,
"max_score": 0,
"hits": []
},
"aggregations": {
"actions per token": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "co8976vymgarwwmianljqcch83ufecdi",
"doc_count": 2479
},
{
"key": "t2vc9j056fkihpvic0ty0rzzq7low29",
"doc_count": 369
},
...
但是如何获得此聚合结果的doc_count的计数?