弹性查询上的嵌套查询聚合

时间:2018-07-17 19:56:30

标签: arrays elasticsearch nested

我正在学习使用具有嵌套结构的elasticsearch数组对象。

这是我的地图

{
  "mappings": {
    "event": {
      "properties": {
        "nodes": {
          "type": "nested", 
          "properties": {
            "node":    { "type": "text"  },
            "count": { "type": "integer"  }
          }
        },"timestamp":{
          "type":"date"
        }
      }
    }
  }
}

这些是数据

{"index":{}}
{"timestamp": "2018-06-10T00:01:00Z", "nodes":[{"36":1}]}
{"index":{}}
{"timestamp": "2018-06-10T00:01:00Z", "nodes":[{"36":1}]}
{"index":{}}
{"timestamp": "2018-06-10T00:01:00Z", "nodes":[{"24":1,"25":1,"28":1}]}
{"index":{}}
{"timestamp": "2018-06-11T00:01:00Z", "nodes":[{"25":1}]}
{"index":{}}
{"timestamp": "2018-06-11T00:01:00Z", "nodes":[{"25":1}]}
{"index":{}}
{"timestamp": "2018-06-11T00:01:00Z", "nodes":[{"23":1,"28":1}]}

如何在每日存储桶中获取结果,并将其值加到键上。

6/10 {“ 36”:2,“ 24”:1,“ 25”:1,“ 28”:1}

6/11 {“ 25”:2,“ 23”:1,“ 28”:1}

谢谢

0 个答案:

没有答案