小编War*_*ore的帖子

Elasticsearch访问直方图

我是Elasticsearch的新手,我无法根据访问范围构建直方图.我甚至不确定是否可以通过在Elasticsearch中使用单个查询来创建此类图表,但我感觉可能通过管道聚合或可能是脚本聚合.

这是我正在使用的测试数据集:

PUT /test_histo
{ "settings": { "number_of_shards": 1 }}

PUT /test_histo/_mapping/visit
{
   "properties": {
      "user": {"type": "string" },
      "datevisit": {"type": "date"},
      "page": {"type": "string"}
   }
}

POST test_histo/visit/_bulk
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"John","page":"home.html","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"Jean","page":"productXX.hmtl","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"Robert","page":"home.html","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"Mary","page":"home.html","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"Mary","page":"media_center.html","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"John","page":"home.html","datevisit":"2015-11-25"}
{"index":{"_index":"test_histo","_type":"visit"}}
{"user":"John","page":"media_center.html","datevisit":"2015-11-26"}
Run Code Online (Sandbox Code Playgroud)

如果我们考虑范围[1,2 [,[2,3 [,[3,inf.[

预期结果应该是:

  • [1,2 [= 2
  • [2,3 [= 1
  • [3,inf.[= 1

我所有努力找到显示客户访问频率的直方图至今仍未成功.我很乐意提供一些提示,技巧或想法来回答我的问题.

aggregation elasticsearch

6
推荐指数
1
解决办法
343
查看次数

标签 统计

aggregation ×1

elasticsearch ×1