小编tom*_*zon的帖子

ElasticSearch - 过滤嵌套聚合

我在过滤后汇总结果时遇到问题.我想我走在正确的轨道上,但我觉得我在追逐自己的尾巴.

以下是它的外观:

PUT /my_index
{
  "mappings": {
    "reporting": {
      "properties": {
        "events": {
          "type": "nested", 
          "properties": {
            "name":    { "type": "string", "index" : "not_analyzed"  },
            "date":    { "type": "date"    }
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

所以,我的文档看起来像:

{
  "events": [
    { "name": "INSTALL", "date": "2014-11-01" },
    { "name": "UNINSTALL", "date": "2014-11-03" },
    { "name": "INSTALL", "date": "2014-11-04" },
    ...
  ]
}
Run Code Online (Sandbox Code Playgroud)

现在,当我索引一些数据时,例如:

PUT /my_index/reporting/1
{
  "events": [
    {
       "name": "INSTALL",
       "date": "2014-11-01"
    },
    {
       "name": "UNINSTALL",
       "date": "2014-11-05"
    }
 ] …
Run Code Online (Sandbox Code Playgroud)

nested filter aggregation elasticsearch

9
推荐指数
1
解决办法
2225
查看次数

标签 统计

aggregation ×1

elasticsearch ×1

filter ×1

nested ×1